mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-04 02:30:24 +01:00
2005-06-15 Dan Williams <dcbw@redhat.com>
Patch from Robert Love: make the applet stetic * gnome/applet/Makefile.am - Don't compile the gtkcellview and gtkcellrendererprogress files * gnome/applet/gtkcellview.h gnome/applet/gtkcellview.c gnome/applet/gtkcellrendererprogress.h gnome/applet/gtkcellrendererprogress.c - Removed * gnome/applet/menu-items.c - Progress bars are 5:1 size ratio - Use GTK progress bars rather than internal ones git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@689 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
f14508aa27
commit
ea848843ab
7 changed files with 43 additions and 1598 deletions
17
ChangeLog
17
ChangeLog
|
|
@ -1,3 +1,20 @@
|
|||
2005-06-15 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
Patch from Robert Love: make the applet stetic
|
||||
|
||||
* gnome/applet/Makefile.am
|
||||
- Don't compile the gtkcellview and gtkcellrendererprogress files
|
||||
|
||||
* gnome/applet/gtkcellview.h
|
||||
gnome/applet/gtkcellview.c
|
||||
gnome/applet/gtkcellrendererprogress.h
|
||||
gnome/applet/gtkcellrendererprogress.c
|
||||
- Removed
|
||||
|
||||
* gnome/applet/menu-items.c
|
||||
- Progress bars are 5:1 size ratio
|
||||
- Use GTK progress bars rather than internal ones
|
||||
|
||||
2005-06-15 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
Patch from Robert Love:
|
||||
|
|
|
|||
|
|
@ -52,10 +52,6 @@ nm_applet_SOURCES = \
|
|||
passphrase-dialog.h \
|
||||
menu-items.c \
|
||||
menu-items.h \
|
||||
gtkcellview.c \
|
||||
gtkcellview.h \
|
||||
gtkcellrendererprogress.c \
|
||||
gtkcellrendererprogress.h \
|
||||
eggtrayicon.c \
|
||||
eggtrayicon.h \
|
||||
vpn-password-dialog.c \
|
||||
|
|
|
|||
|
|
@ -1,387 +0,0 @@
|
|||
/* gtkcellrendererprogress.c
|
||||
* Copyright (C) 2002 Naba Kumar <kh_naba@users.sourceforge.net>
|
||||
* heavily modified by Jörgen Scheibengruber <mfcn@gmx.de>
|
||||
* heavily modified by Marco Pesenti Gritti <marco@gnome.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
/*
|
||||
* Modified by the GTK+ Team and others 1997-2004. See the AUTHORS
|
||||
* file for a list of people on the GTK+ Team. See the ChangeLog
|
||||
* files for a list of changes. These files are distributed with
|
||||
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
||||
*/
|
||||
|
||||
/* GtkCellRendererProgress is public in GTK 2.6, but not in GTK 2.4.
|
||||
*/
|
||||
|
||||
#include <gtk/gtkversion.h>
|
||||
|
||||
#if (GTK_MAJOR_VERSION <= 2 && GTK_MINOR_VERSION < 6)
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "gtkcellrendererprogress.h"
|
||||
#define _(x) (x)
|
||||
#define P_(x) (x)
|
||||
#define Q_(x) (x)
|
||||
#define N_(x) (x)
|
||||
|
||||
#define GTK_CELL_RENDERER_PROGRESS_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), \
|
||||
GTK_TYPE_CELL_RENDERER_PROGRESS, \
|
||||
GtkCellRendererProgressPrivate))
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_VALUE,
|
||||
PROP_TEXT
|
||||
};
|
||||
|
||||
struct _GtkCellRendererProgressPrivate
|
||||
{
|
||||
gint value;
|
||||
gchar *text;
|
||||
gchar *label;
|
||||
gint min_h;
|
||||
gint min_w;
|
||||
};
|
||||
|
||||
static void gtk_cell_renderer_progress_finalize (GObject *object);
|
||||
static void gtk_cell_renderer_progress_get_property (GObject *object,
|
||||
guint param_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_cell_renderer_progress_set_property (GObject *object,
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_cell_renderer_progress_set_value (GtkCellRendererProgress *cellprogress,
|
||||
gint value);
|
||||
static void gtk_cell_renderer_progress_set_text (GtkCellRendererProgress *cellprogress,
|
||||
const gchar *text);
|
||||
static void compute_dimensions (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
const gchar *text,
|
||||
gint *width,
|
||||
gint *height);
|
||||
static void gtk_cell_renderer_progress_get_size (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
GdkRectangle *cell_area,
|
||||
gint *x_offset,
|
||||
gint *y_offset,
|
||||
gint *width,
|
||||
gint *height);
|
||||
static void gtk_cell_renderer_progress_render (GtkCellRenderer *cell,
|
||||
GdkWindow *window,
|
||||
GtkWidget *widget,
|
||||
GdkRectangle *background_area,
|
||||
GdkRectangle *cell_area,
|
||||
GdkRectangle *expose_area,
|
||||
guint flags);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GtkCellRendererProgress, gtk_cell_renderer_progress, GTK_TYPE_CELL_RENDERER);
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_progress_class_init (GtkCellRendererProgressClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (klass);
|
||||
|
||||
object_class->finalize = gtk_cell_renderer_progress_finalize;
|
||||
object_class->get_property = gtk_cell_renderer_progress_get_property;
|
||||
object_class->set_property = gtk_cell_renderer_progress_set_property;
|
||||
|
||||
cell_class->get_size = gtk_cell_renderer_progress_get_size;
|
||||
cell_class->render = gtk_cell_renderer_progress_render;
|
||||
|
||||
/**
|
||||
* GtkCellRendererProgress:value:
|
||||
*
|
||||
* The "value" property determines the percentage to which the
|
||||
* progress bar will be "filled in".
|
||||
*
|
||||
* Since: 2.6
|
||||
**/
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_VALUE,
|
||||
g_param_spec_int ("value",
|
||||
P_("Value"),
|
||||
P_("Value of the progress bar"),
|
||||
0, 100, 0,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
/**
|
||||
* GtkCellRendererProgress:text:
|
||||
*
|
||||
* The "text" property determines the label which will be drawn
|
||||
* over the progress bar. Setting this property to %NULL causes the default
|
||||
* label to be displayed. Setting this property to an empty string causes
|
||||
* no label to be displayed.
|
||||
*
|
||||
* Since: 2.6
|
||||
**/
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_TEXT,
|
||||
g_param_spec_string ("text",
|
||||
P_("Text"),
|
||||
P_("Text on the progress bar"),
|
||||
NULL,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_type_class_add_private (object_class,
|
||||
sizeof (GtkCellRendererProgressPrivate));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_progress_init (GtkCellRendererProgress *cellprogress)
|
||||
{
|
||||
cellprogress->priv = GTK_CELL_RENDERER_PROGRESS_GET_PRIVATE (cellprogress);
|
||||
cellprogress->priv->value = 0;
|
||||
cellprogress->priv->text = NULL;
|
||||
cellprogress->priv->label = NULL;
|
||||
cellprogress->priv->min_w = -1;
|
||||
cellprogress->priv->min_h = -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gtk_cell_renderer_progress_new:
|
||||
*
|
||||
* Creates a new #GtkCellRendererProgress.
|
||||
*
|
||||
* Return value: the new cell renderer
|
||||
*
|
||||
* Since: 2.6
|
||||
**/
|
||||
GtkCellRenderer*
|
||||
gtk_cell_renderer_progress_new (void)
|
||||
{
|
||||
return GTK_CELL_RENDERER (g_object_new (GTK_TYPE_CELL_RENDERER_PROGRESS, NULL));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_progress_finalize (GObject *object)
|
||||
{
|
||||
GtkCellRendererProgress *cellprogress = GTK_CELL_RENDERER_PROGRESS (object);
|
||||
|
||||
g_free (cellprogress->priv->text);
|
||||
g_free (cellprogress->priv->label);
|
||||
|
||||
G_OBJECT_CLASS (gtk_cell_renderer_progress_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_progress_get_property (GObject *object,
|
||||
guint param_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkCellRendererProgress *cellprogress = GTK_CELL_RENDERER_PROGRESS (object);
|
||||
|
||||
switch (param_id)
|
||||
{
|
||||
case PROP_VALUE:
|
||||
g_value_set_int (value, cellprogress->priv->value);
|
||||
break;
|
||||
case PROP_TEXT:
|
||||
g_value_set_string (value, cellprogress->priv->text);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_progress_set_property (GObject *object,
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkCellRendererProgress *cellprogress = GTK_CELL_RENDERER_PROGRESS (object);
|
||||
|
||||
switch (param_id)
|
||||
{
|
||||
case PROP_VALUE:
|
||||
gtk_cell_renderer_progress_set_value (cellprogress,
|
||||
g_value_get_int (value));
|
||||
break;
|
||||
case PROP_TEXT:
|
||||
gtk_cell_renderer_progress_set_text (cellprogress,
|
||||
g_value_get_string (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_progress_set_value (GtkCellRendererProgress *cellprogress,
|
||||
gint value)
|
||||
{
|
||||
gchar *text;
|
||||
|
||||
cellprogress->priv->value = value;
|
||||
|
||||
if (cellprogress->priv->text)
|
||||
text = g_strdup (cellprogress->priv->text);
|
||||
else
|
||||
text = g_strdup_printf (Q_("progress bar label|%d %%"),
|
||||
cellprogress->priv->value);
|
||||
|
||||
g_free (cellprogress->priv->label);
|
||||
cellprogress->priv->label = text;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_progress_set_text (GtkCellRendererProgress *cellprogress,
|
||||
const gchar *text)
|
||||
{
|
||||
gchar *new_text;
|
||||
|
||||
new_text = g_strdup (text);
|
||||
g_free (cellprogress->priv->text);
|
||||
cellprogress->priv->text = new_text;
|
||||
|
||||
/* Update the label */
|
||||
gtk_cell_renderer_progress_set_value (cellprogress, cellprogress->priv->value);
|
||||
}
|
||||
|
||||
static void
|
||||
compute_dimensions (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
const gchar *text,
|
||||
gint *width,
|
||||
gint *height)
|
||||
{
|
||||
PangoRectangle logical_rect;
|
||||
PangoLayout *layout;
|
||||
|
||||
layout = gtk_widget_create_pango_layout (widget, text);
|
||||
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
|
||||
|
||||
if (width)
|
||||
*width = logical_rect.width + cell->xpad * 2 + widget->style->xthickness * 2;
|
||||
|
||||
if (height)
|
||||
*height = logical_rect.height + cell->ypad * 2 + widget->style->ythickness * 2;
|
||||
|
||||
g_object_unref (G_OBJECT (layout));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_progress_get_size (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
GdkRectangle *cell_area,
|
||||
gint *x_offset,
|
||||
gint *y_offset,
|
||||
gint *width,
|
||||
gint *height)
|
||||
{
|
||||
GtkCellRendererProgress *cellprogress = GTK_CELL_RENDERER_PROGRESS (cell);
|
||||
gint w, h;
|
||||
gchar *text;
|
||||
|
||||
if (cellprogress->priv->min_w < 0)
|
||||
{
|
||||
text = g_strdup_printf (Q_("progress bar label|%d %%"), 100);
|
||||
compute_dimensions (cell, widget, text,
|
||||
&cellprogress->priv->min_w,
|
||||
&cellprogress->priv->min_h);
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
compute_dimensions (cell, widget, cellprogress->priv->label, &w, &h);
|
||||
|
||||
if (width)
|
||||
*width = MAX (cellprogress->priv->min_w, w);
|
||||
|
||||
if (height)
|
||||
*height = MIN (cellprogress->priv->min_h, h);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_progress_render (GtkCellRenderer *cell,
|
||||
GdkWindow *window,
|
||||
GtkWidget *widget,
|
||||
GdkRectangle *background_area,
|
||||
GdkRectangle *cell_area,
|
||||
GdkRectangle *expose_area,
|
||||
guint flags)
|
||||
{
|
||||
GtkCellRendererProgress *cellprogress = GTK_CELL_RENDERER_PROGRESS (cell);
|
||||
GdkGC *gc;
|
||||
PangoLayout *layout;
|
||||
PangoRectangle logical_rect;
|
||||
gint x, y, w, h, perc_w, pos;
|
||||
GdkRectangle clip;
|
||||
gboolean is_rtl;
|
||||
|
||||
is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
|
||||
|
||||
gc = gdk_gc_new (window);
|
||||
|
||||
x = cell_area->x + cell->xpad;
|
||||
y = cell_area->y + cell->ypad;
|
||||
|
||||
w = cell_area->width - cell->xpad * 2;
|
||||
h = cell_area->height - cell->ypad * 2;
|
||||
|
||||
gdk_gc_set_rgb_fg_color (gc, &widget->style->fg[GTK_STATE_NORMAL]);
|
||||
gdk_draw_rectangle (window, gc, TRUE, x, y, w, h);
|
||||
|
||||
x += widget->style->xthickness;
|
||||
y += widget->style->ythickness;
|
||||
w -= widget->style->xthickness * 2;
|
||||
h -= widget->style->ythickness * 2;
|
||||
gdk_gc_set_rgb_fg_color (gc, &widget->style->bg[GTK_STATE_NORMAL]);
|
||||
gdk_draw_rectangle (window, gc, TRUE, x, y, w, h);
|
||||
|
||||
gdk_gc_set_rgb_fg_color (gc, &widget->style->bg[GTK_STATE_SELECTED]);
|
||||
perc_w = w * MAX (0, cellprogress->priv->value) / 100;
|
||||
gdk_draw_rectangle (window, gc, TRUE, is_rtl ? (x + w - perc_w) : x, y, perc_w, h);
|
||||
|
||||
layout = gtk_widget_create_pango_layout (widget, cellprogress->priv->label);
|
||||
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
|
||||
|
||||
pos = (w - logical_rect.width)/2;
|
||||
|
||||
clip.x = x;
|
||||
clip.y = y;
|
||||
clip.width = is_rtl ? w - perc_w : perc_w;
|
||||
clip.height = h;
|
||||
|
||||
gtk_paint_layout (widget->style, window,
|
||||
is_rtl ? GTK_STATE_NORMAL : GTK_STATE_SELECTED,
|
||||
FALSE, &clip, widget, "progressbar",
|
||||
x + pos, y + (h - logical_rect.height)/2,
|
||||
layout);
|
||||
|
||||
clip.x = clip.x + clip.width;
|
||||
clip.width = w - clip.width;
|
||||
|
||||
gtk_paint_layout (widget->style, window,
|
||||
is_rtl ? GTK_STATE_SELECTED : GTK_STATE_NORMAL,
|
||||
FALSE, &clip, widget, "progressbar",
|
||||
x + pos, y + (h - logical_rect.height)/2,
|
||||
layout);
|
||||
|
||||
g_object_unref (G_OBJECT (layout));
|
||||
g_object_unref (G_OBJECT (gc));
|
||||
}
|
||||
|
||||
#endif /* GTK < 2.6 check */
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
/* gtkcellrendererprogress.h
|
||||
* Copyright (C) 2002 Naba Kumar <kh_naba@users.sourceforge.net>
|
||||
* modified by Jörgen Scheibengruber <mfcn@gmx.de>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
/*
|
||||
* Modified by the GTK+ Team and others 1997-2004. See the AUTHORS
|
||||
* file for a list of people on the GTK+ Team. See the ChangeLog
|
||||
* files for a list of changes. These files are distributed with
|
||||
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
||||
*/
|
||||
|
||||
|
||||
/* GtkCellRendererProgress is public in GTK 2.6, but not in GTK 2.4.
|
||||
*/
|
||||
|
||||
#include <gtk/gtkversion.h>
|
||||
|
||||
#if (GTK_MAJOR_VERSION <= 2 && GTK_MINOR_VERSION < 6)
|
||||
|
||||
#ifndef __GTK_CELL_RENDERER_PROGRESS_H__
|
||||
#define __GTK_CELL_RENDERER_PROGRESS_H__
|
||||
|
||||
#include <gtk/gtkcellrenderer.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_CELL_RENDERER_PROGRESS (gtk_cell_renderer_progress_get_type ())
|
||||
#define GTK_CELL_RENDERER_PROGRESS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CELL_RENDERER_PROGRESS, GtkCellRendererProgress))
|
||||
#define GTK_CELL_RENDERER_PROGRESS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_CELL_RENDERER_PROGRESS, GtkCellRendererProgressClass))
|
||||
#define GTK_IS_CELL_RENDERER_PROGRESS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_CELL_RENDERER_PROGRESS))
|
||||
#define GTK_IS_CELL_RENDERER_PROGRESS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CELL_RENDERER_PROGRESS))
|
||||
#define GTK_CELL_RENDERER_PROGRESS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CELL_RENDERER_PROGRESS, GtkCellRendererProgressClass))
|
||||
|
||||
typedef struct _GtkCellRendererProgress GtkCellRendererProgress;
|
||||
typedef struct _GtkCellRendererProgressClass GtkCellRendererProgressClass;
|
||||
typedef struct _GtkCellRendererProgressPrivate GtkCellRendererProgressPrivate;
|
||||
|
||||
struct _GtkCellRendererProgress
|
||||
{
|
||||
GtkCellRenderer parent_instance;
|
||||
|
||||
/*< private >*/
|
||||
GtkCellRendererProgressPrivate *priv;
|
||||
};
|
||||
|
||||
struct _GtkCellRendererProgressClass
|
||||
{
|
||||
GtkCellRendererClass parent_class;
|
||||
|
||||
/* Padding for future expansion */
|
||||
void (*_gtk_reserved1) (void);
|
||||
void (*_gtk_reserved2) (void);
|
||||
void (*_gtk_reserved3) (void);
|
||||
void (*_gtk_reserved4) (void);
|
||||
};
|
||||
|
||||
GType gtk_cell_renderer_progress_get_type (void);
|
||||
GtkCellRenderer* gtk_cell_renderer_progress_new (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_CELL_RENDERER_PROGRESS_H__ */
|
||||
|
||||
#endif /* GTK < 2.6 check */
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,95 +0,0 @@
|
|||
/* gtkcellview.h
|
||||
* Copyright (C) 2002, 2003 Kristian Rietveld <kris@gtk.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* GtkCellView is public in GTK 2.6, but not in GTK 2.4. We can't include
|
||||
* this private copy of GtkCellView when using GTK 2.6 due to link-time errors.
|
||||
*/
|
||||
|
||||
#include <gtk/gtkversion.h>
|
||||
|
||||
#if (GTK_MAJOR_VERSION <= 2 && GTK_MINOR_VERSION < 6)
|
||||
|
||||
#ifndef __GTK_CELL_VIEW_H__
|
||||
#define __GTK_CELL_VIEW_H__
|
||||
|
||||
#include <gtk/gtkwidget.h>
|
||||
#include <gtk/gtkcellrenderer.h>
|
||||
#include <gtk/gtktreemodel.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_CELL_VIEW (gtk_cell_view_get_type ())
|
||||
#define GTK_CELL_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CELL_VIEW, GtkCellView))
|
||||
#define GTK_CELL_VIEW_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), GTK_TYPE_CELL_VIEW, GtkCellViewClass))
|
||||
#define GTK_IS_CELL_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_CELL_VIEW))
|
||||
#define GTK_IS_CELL_VIEW_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), GTK_TYPE_CELL_VIEW))
|
||||
#define GTK_CELL_VIEW_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), GTK_TYPE_CELL_VIEW, GtkCellViewClass))
|
||||
|
||||
typedef struct _GtkCellView GtkCellView;
|
||||
typedef struct _GtkCellViewClass GtkCellViewClass;
|
||||
typedef struct _GtkCellViewPrivate GtkCellViewPrivate;
|
||||
|
||||
struct _GtkCellView
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
|
||||
/*< private >*/
|
||||
GtkCellViewPrivate *priv;
|
||||
};
|
||||
|
||||
struct _GtkCellViewClass
|
||||
{
|
||||
GtkWidgetClass parent_class;
|
||||
};
|
||||
|
||||
GType gtk_cell_view_get_type (void);
|
||||
GtkWidget *gtk_cell_view_new (void);
|
||||
GtkWidget *gtk_cell_view_new_with_text (const gchar *text);
|
||||
GtkWidget *gtk_cell_view_new_with_markup (const gchar *markup);
|
||||
GtkWidget *gtk_cell_view_new_with_pixbuf (GdkPixbuf *pixbuf);
|
||||
|
||||
|
||||
void gtk_cell_view_set_value (GtkCellView *cell_view,
|
||||
GtkCellRenderer *renderer,
|
||||
gchar *property,
|
||||
GValue *value);
|
||||
void gtk_cell_view_set_values (GtkCellView *cell_view,
|
||||
GtkCellRenderer *renderer,
|
||||
...);
|
||||
|
||||
void gtk_cell_view_set_model (GtkCellView *cell_view,
|
||||
GtkTreeModel *model);
|
||||
void gtk_cell_view_set_displayed_row (GtkCellView *cell_view,
|
||||
GtkTreePath *path);
|
||||
GtkTreePath *gtk_cell_view_get_displayed_row (GtkCellView *cell_view);
|
||||
gboolean gtk_cell_view_get_size_of_row (GtkCellView *cell_view,
|
||||
GtkTreePath *path,
|
||||
GtkRequisition *requisition);
|
||||
|
||||
void gtk_cell_view_set_background_color (GtkCellView *cell_view,
|
||||
const GdkColor *color);
|
||||
void gtk_cell_view_set_cell_data (GtkCellView *cellview);
|
||||
GList *gtk_cell_view_get_cell_renderers (GtkCellView *cellview);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_CELL_VIEW_H__ */
|
||||
|
||||
|
||||
#endif /* GTK < 2.6 check */
|
||||
|
|
@ -33,13 +33,8 @@
|
|||
#include <stdio.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "menu-items.h"
|
||||
|
||||
#if (GTK_MAJOR_VERSION <= 2 && GTK_MINOR_VERSION < 6)
|
||||
#include "gtkcellview.h"
|
||||
#include "gtkcellrendererprogress.h"
|
||||
#endif
|
||||
|
||||
#include "applet-dbus.h"
|
||||
|
||||
|
||||
|
|
@ -180,9 +175,8 @@ struct NMNetworkMenuItem
|
|||
{
|
||||
GtkCheckMenuItem *check_item;
|
||||
GtkLabel *label;
|
||||
GtkWidget *cell_view;
|
||||
GtkWidget *progress;
|
||||
GtkWidget *security_image;
|
||||
GObject *progress_bar;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -190,6 +184,11 @@ NMNetworkMenuItem *network_menu_item_new (GtkSizeGroup *encryption_size_group)
|
|||
{
|
||||
GtkWidget *hbox;
|
||||
NMNetworkMenuItem *item = g_malloc0 (sizeof (NMNetworkMenuItem));
|
||||
PangoFontDescription *fontdesc;
|
||||
PangoFontMetrics *metrics;
|
||||
PangoContext *context;
|
||||
PangoLanguage *lang;
|
||||
int ascent;
|
||||
|
||||
g_return_val_if_fail (item != NULL, NULL);
|
||||
|
||||
|
|
@ -205,15 +204,25 @@ NMNetworkMenuItem *network_menu_item_new (GtkSizeGroup *encryption_size_group)
|
|||
|
||||
gtk_container_add (GTK_CONTAINER (item->check_item), hbox);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (item->label), TRUE, TRUE, 0);
|
||||
item->cell_view = gtk_cell_view_new ();
|
||||
item->progress_bar = g_object_new (GTK_TYPE_CELL_RENDERER_PROGRESS, "text", "", NULL);
|
||||
gtk_cell_renderer_set_fixed_size (GTK_CELL_RENDERER (item->progress_bar), 150, -1);
|
||||
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (item->cell_view), GTK_CELL_RENDERER (item->progress_bar), TRUE);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), item->cell_view, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), item->security_image, FALSE, FALSE, 0);
|
||||
|
||||
item->progress = gtk_progress_bar_new ();
|
||||
|
||||
/* get the font ascent for the current font and language */
|
||||
context = gtk_widget_get_pango_context (item->progress);
|
||||
fontdesc = pango_context_get_font_description (context);
|
||||
lang = pango_context_get_language (context);
|
||||
metrics = pango_context_get_metrics (context, fontdesc, lang);
|
||||
ascent = pango_font_metrics_get_ascent (metrics) * 1.5 / PANGO_SCALE;
|
||||
pango_font_metrics_unref (metrics);
|
||||
|
||||
/* size our progress bar to be five ascents long, one high */
|
||||
gtk_widget_set_size_request (item->progress, ascent * 5, ascent / 2);
|
||||
|
||||
gtk_box_pack_end (GTK_BOX (hbox), item->progress, FALSE, TRUE, 0);
|
||||
|
||||
gtk_widget_show (GTK_WIDGET (item->label));
|
||||
gtk_widget_show (item->cell_view);
|
||||
gtk_widget_show (item->progress);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
return item;
|
||||
|
|
@ -232,6 +241,7 @@ GtkCheckMenuItem *network_menu_item_get_check_item (NMNetworkMenuItem *item)
|
|||
void network_menu_item_update (NMNetworkMenuItem *item, WirelessNetwork *network, const gboolean is_encrypted)
|
||||
{
|
||||
char *display_essid;
|
||||
gdouble percent;
|
||||
|
||||
g_return_if_fail (item != NULL);
|
||||
g_return_if_fail (network != NULL);
|
||||
|
|
@ -240,7 +250,8 @@ void network_menu_item_update (NMNetworkMenuItem *item, WirelessNetwork *network
|
|||
gtk_label_set_text (GTK_LABEL (item->label), display_essid);
|
||||
g_free (display_essid);
|
||||
|
||||
g_object_set (G_OBJECT (item->progress_bar), "value", CLAMP ((int) wireless_network_get_strength (network), 0, 100), NULL);
|
||||
percent = (double) CLAMP (wireless_network_get_strength (network), 0, 100) / 100.0;
|
||||
gtk_progress_set_percentage (GTK_PROGRESS (item->progress), percent);
|
||||
|
||||
/* Deal with the encrypted icon */
|
||||
g_object_set (item->security_image, "visible", is_encrypted, NULL);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue