[gnome-nettool] Get working with latest GTK3
- From: Germán Poó Caamaño <gpoo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-nettool] Get working with latest GTK3
- Date: Tue, 11 Jan 2011 07:34:32 +0000 (UTC)
commit 5547b2fe5bc90252eeb77ec2f84909b1f1efd786
Author: Robert Ancell <robert ancell canonical com>
Date: Thu Dec 2 15:47:09 2010 +1100
Get working with latest GTK3
https://bugzilla.gnome.org/show_bug.cgi?id=636272
Signed-off-by: Germán Póo-Caamaño <gpoo gnome org>
configure.ac | 23 ++---------------------
data/gnome-nettool.ui | 21 ++++++++++++++-------
src/gn-combo-history.c | 4 ++--
src/main.c | 22 +++++++++++-----------
src/ping.c | 41 ++++++++++++++++++++++-------------------
src/ping.h | 3 +--
6 files changed, 52 insertions(+), 62 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 3d7f48b..9ab571d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -31,29 +31,10 @@ dnl ******************************************
dnl ** pkg-config dependacy checks **
dnl ******************************************
GIO_REQUIRED=2.25.10
-GTK_REQUIRED=2.90.0
-
-AC_MSG_CHECKING([which gtk+ version to compile against])
-AC_ARG_WITH([gtk],
- [AS_HELP_STRING([--with-gtk=2.0|3.0],[which gtk+ version to compile against (default: 2.0)])],
- [case "$with_gtk" in
- 2.0|3.0) ;;
- *) AC_MSG_ERROR([invalid gtk version specified]) ;;
- esac],
- [with_gtk=2.0])
-AC_MSG_RESULT([$with_gtk])
-
-case "$with_gtk" in
- 2.0) GTK_API_VERSION=2.0
- GTK_REQUIRED=2.19.7
- ;;
- 3.0) GTK_API_VERSION=3.0
- GTK_REQUIRED=2.90.4
- ;;
-esac
+GTK_REQUIRED=2.90.4
PKG_CHECK_MODULES(NETTOOL,
- gtk+-$GTK_API_VERSION >= $GTK_REQUIRED
+ gtk+-3.0 >= $GTK_REQUIRED
gio-2.0 >= $GIO_REQUIRED
gmodule-export-2.0
gnome-doc-utils
diff --git a/data/gnome-nettool.ui b/data/gnome-nettool.ui
index 7bc5adf..83c0577 100644
--- a/data/gnome-nettool.ui
+++ b/data/gnome-nettool.ui
@@ -939,9 +939,10 @@
</packing>
</child>
<child>
- <object class="GtkComboBoxEntry" id="ping_host">
+ <object class="GtkComboBox" id="ping_host">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="has_entry">True</property>
<accessibility>
<relation target="ping_host_label" type="labelled-by"/>
</accessibility>
@@ -1638,9 +1639,10 @@
</packing>
</child>
<child>
- <object class="GtkComboBoxEntry" id="traceroute_host">
+ <object class="GtkComboBox" id="traceroute_host">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="has_entry">True</property>
<child internal-child="entry">
<object class="GtkEntry" id="comboboxentry-entry2">
<property name="has_tooltip">True</property>
@@ -1789,9 +1791,10 @@
</packing>
</child>
<child>
- <object class="GtkComboBoxEntry" id="scan_host">
+ <object class="GtkComboBox" id="scan_host">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="has_entry">True</property>
<child internal-child="entry">
<object class="GtkEntry" id="comboboxentry-entry3">
<property name="has_tooltip">True</property>
@@ -1963,9 +1966,10 @@
</packing>
</child>
<child>
- <object class="GtkComboBoxEntry" id="lookup_host">
+ <object class="GtkComboBox" id="lookup_host">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="has_entry">True</property>
<child internal-child="entry">
<object class="GtkEntry" id="comboboxentry-entry4">
<property name="has_tooltip">True</property>
@@ -2126,9 +2130,10 @@
<property name="column_spacing">6</property>
<property name="row_spacing">6</property>
<child>
- <object class="GtkComboBoxEntry" id="finger_host">
+ <object class="GtkComboBox" id="finger_host">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="has_entry">True</property>
<child internal-child="entry">
<object class="GtkEntry" id="comboboxentry-entry6">
<property name="has_tooltip">True</property>
@@ -2161,9 +2166,10 @@
</packing>
</child>
<child>
- <object class="GtkComboBoxEntry" id="finger_user">
+ <object class="GtkComboBox" id="finger_user">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="has_entry">True</property>
<child internal-child="entry">
<object class="GtkEntry" id="comboboxentry-entry5">
<property name="has_tooltip">True</property>
@@ -2347,9 +2353,10 @@
</packing>
</child>
<child>
- <object class="GtkComboBoxEntry" id="whois_host">
+ <object class="GtkComboBox" id="whois_host">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="has_entry">True</property>
<child internal-child="entry">
<object class="GtkEntry" id="comboboxentry-entry7">
<property name="has_tooltip">True</property>
diff --git a/src/gn-combo-history.c b/src/gn-combo-history.c
index 09e2566..5ae5b7d 100644
--- a/src/gn-combo-history.c
+++ b/src/gn-combo-history.c
@@ -271,8 +271,8 @@ gn_combo_history_set_popdown_strings (GnComboHistory *history)
if (!model)
return;
- text_column = gtk_combo_box_entry_get_text_column (
- GTK_COMBO_BOX_ENTRY (history->priv->combo));
+ text_column = gtk_combo_box_get_entry_text_column (
+ GTK_COMBO_BOX (history->priv->combo));
gtk_list_store_clear (GTK_LIST_STORE (model));
diff --git a/src/main.c b/src/main.c
index 17c3377..94b7d37 100644
--- a/src/main.c
+++ b/src/main.c
@@ -53,7 +53,7 @@ int
main (int argc, char *argv[])
{
GtkWidget *window;
- GtkWidget *menu_beep;
+ GtkAction *menu_beep;
GtkBuilder *builder;
GtkWidget *notebook;
GtkWidget *statusbar;
@@ -217,7 +217,7 @@ main (int argc, char *argv[])
g_object_set_data (G_OBJECT (notebook), "finger", finger);
g_object_set_data (G_OBJECT (notebook), "whois", whois);
- menu_beep = GTK_WIDGET (gtk_builder_get_object (builder, "m_beep"));
+ menu_beep = GTK_ACTION (gtk_builder_get_object (builder, "m_beep"));
g_signal_connect (G_OBJECT (menu_beep), "activate",
G_CALLBACK (on_beep_activate),
@@ -315,7 +315,7 @@ load_ping_widgets_from_builder (GtkBuilder * builder)
gtk_combo_box_set_model (GTK_COMBO_BOX (pinger->host), model);
g_object_unref (model);
- gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (pinger->host), 0);
+ gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (pinger->host), 0);
entry_host = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (pinger->host)));
@@ -339,8 +339,8 @@ load_ping_widgets_from_builder (GtkBuilder * builder)
g_signal_connect (G_OBJECT (pinger->button), "clicked",
pinger->button_callback,
pinger);
- g_signal_connect (G_OBJECT (pinger->graph), "expose-event",
- G_CALLBACK (on_ping_graph_expose),
+ g_signal_connect (G_OBJECT (pinger->graph), "draw",
+ G_CALLBACK (on_ping_graph_draw),
pinger);
return pinger;
@@ -394,7 +394,7 @@ load_traceroute_widgets_from_builder (GtkBuilder * builder)
gtk_combo_box_set_model (GTK_COMBO_BOX (tracer->host), model);
g_object_unref (model);
- gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (tracer->host), 0);
+ gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (tracer->host), 0);
entry_host = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (tracer->host)));
@@ -631,7 +631,7 @@ load_scan_widgets_from_builder (GtkBuilder * builder)
gtk_combo_box_set_model (GTK_COMBO_BOX (scan->host), model);
g_object_unref (model);
- gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (scan->host), 0);
+ gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (scan->host), 0);
entry_host = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (scan->host)));
@@ -755,7 +755,7 @@ load_lookup_widgets_from_builder (GtkBuilder * builder)
gtk_combo_box_set_model (GTK_COMBO_BOX (lookup->host), model);
g_object_unref (model);
- gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (lookup->host), 0);
+ gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (lookup->host), 0);
entry_host = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (lookup->host)));
@@ -838,7 +838,7 @@ load_finger_widgets_from_builder (GtkBuilder * builder)
gtk_combo_box_set_model (GTK_COMBO_BOX (finger->user), model);
g_object_unref (model);
- gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (finger->user), 0);
+ gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (finger->user), 0);
entry_host = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (finger->user)));
@@ -861,7 +861,7 @@ load_finger_widgets_from_builder (GtkBuilder * builder)
gtk_combo_box_set_model (GTK_COMBO_BOX (finger->host), model);
g_object_unref (model);
- gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (finger->host), 0);
+ gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (finger->host), 0);
entry_host = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (finger->host)));
@@ -942,7 +942,7 @@ load_whois_widgets_from_builder (GtkBuilder * builder)
gtk_combo_box_set_model (GTK_COMBO_BOX (whois->host), model);
g_object_unref (model);
- gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (whois->host), 0);
+ gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (whois->host), 0);
entry_host = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (whois->host)));
diff --git a/src/ping.c b/src/ping.c
index 2c973c3..8eba4fd 100644
--- a/src/ping.c
+++ b/src/ping.c
@@ -51,7 +51,7 @@ typedef struct {
} PingGraphBarData;
static void
-draw_centered_text (GtkWidget *widget, gint x, gint y, gchar *text)
+draw_centered_text (GtkWidget *widget, cairo_t *cr, gint x, gint y, gchar *text)
{
int width;
PangoLayout *layout;
@@ -62,9 +62,9 @@ draw_centered_text (GtkWidget *widget, gint x, gint y, gchar *text)
x -= width/2;
- gtk_paint_layout (gtk_widget_get_style(widget), gtk_widget_get_window(widget),
+ gtk_paint_layout (gtk_widget_get_style(widget), cr,
GTK_STATE_NORMAL, TRUE,
- NULL, NULL, NULL, x, y,
+ widget, NULL, x, y,
layout);
g_object_unref (layout);
}
@@ -119,7 +119,7 @@ get_bar_data (Netinfo *netinfo, PingGraphBarData *bar_data, int ntodisplay,
static void
draw_ping_graph (Netinfo *netinfo)
{
- GdkWindow *window;
+ cairo_t *cr;
GtkStyle *style;
GtkWidget *widget;
PangoLayout *layout;
@@ -137,7 +137,7 @@ draw_ping_graph (Netinfo *netinfo)
gchar *tmpstr;
widget = netinfo->graph;
- window = gtk_widget_get_window(widget);
+ cr = gdk_cairo_create (gtk_widget_get_window(widget));
style = gtk_widget_get_style(widget);
rangemax = packets_transmitted;
@@ -151,7 +151,8 @@ draw_ping_graph (Netinfo *netinfo)
layout = gtk_widget_create_pango_layout (widget, _("Time (ms):"));
/* We guess that the first label is representative. */
pango_layout_get_pixel_size (layout, NULL, &font_height);
- gdk_drawable_get_size (window, &width, &height);
+ width = gtk_widget_get_allocated_width (widget);
+ height = gtk_widget_get_allocated_height (widget);
offset = 0.05*height;
bar_height = height - 2.5*font_height - offset;
@@ -160,21 +161,21 @@ draw_ping_graph (Netinfo *netinfo)
line1h = bar_height + 0.125*font_height + offset;
line2h = bar_height + 1.25*font_height + offset;
- gtk_paint_box (style, window, GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_IN,
- NULL, NULL, NULL, 0, 0, width, height);
+ gtk_paint_box (style, cr, GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_IN,
+ widget, NULL, 0, 0, width, height);
- gtk_paint_layout (style, window, GTK_STATE_NORMAL, TRUE,
- NULL, NULL, NULL, 0.02*width, line1h,
+ gtk_paint_layout (style, cr, GTK_STATE_NORMAL, TRUE,
+ widget, NULL, 0.02*width, line1h,
layout);
g_object_unref (layout);
layout = gtk_widget_create_pango_layout (widget, _("Seq. No.:"));
- gtk_paint_layout (style, window, GTK_STATE_NORMAL, TRUE,
- NULL, NULL, NULL, 0.02*width, line2h,
+ gtk_paint_layout (style, cr, GTK_STATE_NORMAL, TRUE,
+ widget, NULL, 0.02*width, line2h,
layout);
g_object_unref (layout);
- gtk_paint_hline (style, window, GTK_STATE_NORMAL, NULL, NULL, NULL,
+ gtk_paint_hline (style, cr, GTK_STATE_NORMAL, widget, NULL,
0.02*width, 0.98*width, separator_height);
index = 0;
@@ -182,30 +183,32 @@ draw_ping_graph (Netinfo *netinfo)
for (x = 1.5*step; x < width; x += step) {
if (bar_data[index].valid) {
h = scale_factor*bar_data[index].value;
- gtk_paint_flat_box (style, window, GTK_STATE_SELECTED,
- GTK_SHADOW_ETCHED_IN, NULL,
- NULL, NULL, x - 0.4*step,
+ gtk_paint_flat_box (style, cr, GTK_STATE_SELECTED,
+ GTK_SHADOW_ETCHED_IN, widget,
+ NULL, x - 0.4*step,
offset + bar_height - h,
0.8*step, h);
tmpstr = g_strdup_printf ("%.2f", bar_data[index].value);
} else {
tmpstr = g_strdup ("-");
}
- draw_centered_text (widget, x, line1h, tmpstr);
+ draw_centered_text (widget, cr, x, line1h, tmpstr);
g_free (tmpstr);
if (index + rangemin + 1 <= rangemax) {
tmpstr = g_strdup_printf ("%d", index + rangemin + 1);
} else {
tmpstr = g_strdup ("-");
}
- draw_centered_text (widget, x, line2h, tmpstr);
+ draw_centered_text (widget, cr, x, line2h, tmpstr);
g_free (tmpstr);
index++;
}
+
+ cairo_destroy (cr);
}
gint
-on_ping_graph_expose (GtkWidget *widget, GdkEventExpose *event,
+on_ping_graph_draw (GtkWidget *widget, cairo_t *cr,
Netinfo *info)
{
draw_ping_graph (info);
diff --git a/src/ping.h b/src/ping.h
index 0d2e068..0ab1b64 100644
--- a/src/ping.h
+++ b/src/ping.h
@@ -74,5 +74,4 @@ void ping_stop (Netinfo * netinfo);
void ping_foreach (Netinfo * netinfo, gchar * line, gssize len, gpointer user_data);
void ping_foreach_with_tree (Netinfo * netinfo, gchar * line, gint len, gpointer user_data);
void ping_copy_to_clipboard (Netinfo * netinfo, gpointer user_data);
-gint on_ping_graph_expose (GtkWidget *widget, GdkEventExpose *event,
- Netinfo *info);
+gint on_ping_graph_draw (GtkWidget *widget, cairo_t *cr, Netinfo *info);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]