[telegnome] Port to GTK+ 3



commit 33e56d0902a9dd19eeb504db70d435e7cc6cb05e
Author: Colin Watson <cjwatson debian org>
Date:   Wed Feb 3 02:25:03 2016 +0000

    Port to GTK+ 3
    
    * configure.ac (PKG_CHECK_MODULES): Replace gtk+-2.0 with gtk+-3.0.
    Bump cairo requirement to >= 1.10.
    * src/gui.c (tg_gui_print_in_statusbar): Call
    gtk_entry_set_width_chars.  Drop call to
    gtk_widget_set_size_request.
    (tg_gui_new_toolbar): Port to GtkGrid.  Don't use stock items.
    (tg_gui_new): Port to GtkGrid.
    (tg_cb_keypress): Test against GDK_KEY_KP_Enter rather than
    GDK_KP_Enter.
    * src/pixpack.c (tg_pixpack_class_init): Set destroy method on
    GtkWidgetClass rather than GtkObjectClass.  Set draw method rather
    than expose_event method.
    (tg_pixpack_destroy): Take a GtkWidget parameter rather than
    GtkObject.
    (tg_pixpack_realize): Drop calls to gtk_widget_get_colormap,
    gtk_widget_style_attach, and gtk_style_set_background.
    (tg_pixpack_paint): Rename to ...
    (tg_pixpack_draw): ... this.  Adjust for differing draw method
    interface.
    (tg_pixpack_expose): Remove; folded directly into tg_pixpack_draw.
    * src/prefs.c (tg_prefs_edit_channel): Port to GtkGrid.  Use
    xalign/yalign properties on GtkLabel rather than
    gtk_misc_set_alignment.  Don't use stock items.
    (tg_prefs_construct_misc_page, tg_prefs_construct_channels_page):
    Port to GtkGrid.
    (tg_prefs_show): Don't use stock items.
    * src/view.c (tg_view_new): Drop unnecessary GtkVBox container.
    (tg_view_get_widget): Return the pixpack rather than the now-removed
    box.
    (tg_view_free): Clear the pixpack rather than the now-removed box.
    * src/view.h (struct _TgView): Remove box element.

 NEWS          |    1 +
 configure.ac  |    2 +-
 src/gui.c     |   95 ++++++++++++++++++++++++++----------------------
 src/pixpack.c |   79 +++++++++++++++-------------------------
 src/prefs.c   |  113 ++++++++++++++++++++++++++++++---------------------------
 src/view.c    |   10 +----
 src/view.h    |    3 --
 7 files changed, 145 insertions(+), 158 deletions(-)
---
diff --git a/NEWS b/NEWS
index 747a8b3..0afac3a 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ Changes in TeleGNOME 0.2.1
  * Port from GtkCList to GtkTreeView and friends.
  * Port to new (as of GTK+ 2.4) GtkToolbar API.
  * Port from GdkDrawable to Cairo.
+ * Port to GTK+ 3.
 
 Changes in TeleGNOME 0.2.0
 ==========================
diff --git a/configure.ac b/configure.ac
index 3f8ce1c..0537cce 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,7 @@ AC_PROG_INSTALL
 AC_DEFINE_UNQUOTED([SYSCONFDIR], "$sysconfdir", [System configuration directory.])
 
 AM_PATH_GLIB_2_0([2.44.0], [], [AC_MSG_ERROR([GLib >= 2.44.0 is required])], [gobject gio])
-PKG_CHECK_MODULES([TELEGNOME], [gtk+-2.0 >= 2.20 gdk-pixbuf-2.0 >= 2.26 cairo dconf uuid])
+PKG_CHECK_MODULES([TELEGNOME], [gtk+-3.0 gdk-pixbuf-2.0 >= 2.26 cairo >= 1.10 dconf uuid])
 
 AC_ARG_VAR([XMLLINT], [the xmllint program])
 AC_PATH_PROG([XMLLINT], [xmllint])
diff --git a/src/gui.c b/src/gui.c
index 40874e5..606dd16 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -43,7 +43,7 @@ struct _TgGui {
 
     GtkWidget *window;
     GtkAccelGroup *accel_group;
-    GtkWidget *vbox;
+    GtkWidget *grid;
     GtkWidget *progress_bar;
     GtkWidget *status_bar;
 
@@ -343,26 +343,23 @@ tg_gui_print_in_statusbar(const char *buf)  /*FIXME: buffersize*/
 static GtkWidget * 
 tg_gui_new_entry (void)
 {
-       GtkWidget *entry = NULL;
+    GtkWidget *entry = NULL;
+    gint width;
 
-       entry=gtk_entry_new();
-       gtk_entry_set_max_length(GTK_ENTRY(entry),
-                                TG_PAGE_SIZE + 1 + TG_SUBPAGE_SIZE);
+    entry = gtk_entry_new();
+    width = TG_PAGE_SIZE + 1 + TG_SUBPAGE_SIZE;
+    gtk_entry_set_max_length(GTK_ENTRY(entry), width);
+    gtk_entry_set_width_chars(GTK_ENTRY(entry), width);
 
-       /* hack */
-       gtk_widget_set_size_request(GTK_WIDGET(entry),
-                                   (8 * (TG_PAGE_SIZE + 1 + TG_SUBPAGE_SIZE)),
-                                   20);
-
-       /*gtk_entry_set_text(GTK_ENTRY(entry), startpage);*/
-             
-       g_signal_connect(G_OBJECT(entry), "activate", 
-                        G_CALLBACK(tg_gui_cb_goto_page), NULL);
+    /*gtk_entry_set_text(GTK_ENTRY(entry), startpage);*/
+         
+    g_signal_connect(G_OBJECT(entry), "activate", 
+                    G_CALLBACK(tg_gui_cb_goto_page), NULL);
 
-       /* save entry for later ref */
-       gui->entry = entry;
+    /* save entry for later ref */
+    gui->entry = entry;
 
-       return entry;
+    return entry;
 }
 
 
@@ -403,51 +400,62 @@ tg_gui_cb_toggle_paging(GtkWidget *w, gpointer data)
 static GtkWidget *
 tg_gui_new_toolbar (void)
 {
-    GtkWidget *toolbar, *entry, *hbox, *w;
+    GtkWidget *toolbar, *entry, *grid, *w;
     GtkToolItem *toolitem;
 
     toolbar = gtk_toolbar_new();
 
-    hbox = gtk_hbox_new(FALSE, 0);
+    grid = gtk_grid_new();
+    gtk_orientable_set_orientation(GTK_ORIENTABLE(grid),
+                                  GTK_ORIENTATION_HORIZONTAL);
     
     w = gtk_label_new(_("Page:"));
-    gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 5);
-    
+    g_object_set(G_OBJECT(w), "margin", 5, NULL);
+    gtk_container_add(GTK_CONTAINER(grid), w);
+
     /* add the entry */
     entry = tg_gui_new_entry();
     gtk_widget_set_tooltip_text(entry, _("Page number"));
+    g_object_set(G_OBJECT(entry), "margin", 5, NULL);
+    gtk_container_add(GTK_CONTAINER(grid), entry);
 
-    gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 5);
     toolitem = gtk_tool_item_new();
-    gtk_container_add(GTK_CONTAINER(toolitem), hbox);
+    gtk_container_add(GTK_CONTAINER(toolitem), grid);
     gtk_toolbar_insert(GTK_TOOLBAR(toolbar), toolitem, -1);
 
-    toolitem = gtk_tool_button_new_from_stock(GTK_STOCK_JUMP_TO);
+    toolitem = gtk_tool_button_new(NULL, _("_Jump to"));
+    gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(toolitem), "go-jump");
     gtk_widget_set_tooltip_text(GTK_WIDGET(toolitem), _("Go To Page"));
     g_signal_connect(G_OBJECT(toolitem), "clicked",
                     G_CALLBACK(tg_gui_cb_goto_page), NULL);
     gtk_toolbar_insert(GTK_TOOLBAR(toolbar), toolitem, -1);
 
-    toolitem = gtk_tool_button_new_from_stock(GTK_STOCK_GO_BACK);
+    toolitem = gtk_tool_button_new(NULL, _("_Back"));
+    gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(toolitem), "go-previous");
     gtk_widget_set_tooltip_text(GTK_WIDGET(toolitem), _("Get Previous Page"));
     g_signal_connect(G_OBJECT(toolitem), "clicked",
                     G_CALLBACK(tg_gui_cb_prev_page), NULL);
     gtk_toolbar_insert(GTK_TOOLBAR(toolbar), toolitem, -1);
 
-    toolitem = gtk_tool_button_new_from_stock(GTK_STOCK_GO_FORWARD);
+    toolitem = gtk_tool_button_new(NULL, _("_Forward"));
+    gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(toolitem), "go-next");
     gtk_widget_set_tooltip_text(GTK_WIDGET(toolitem), _("Get Next Page"));
     g_signal_connect(G_OBJECT(toolitem), "clicked",
                     G_CALLBACK(tg_gui_cb_next_page), NULL);
     gtk_toolbar_insert(GTK_TOOLBAR(toolbar), toolitem, -1);
 
-    toolitem = gtk_tool_button_new_from_stock(GTK_STOCK_HOME);
+    toolitem = gtk_tool_button_new(NULL, _("_Home"));
+    gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(toolitem), "go-home");
     gtk_widget_set_tooltip_text(GTK_WIDGET(toolitem),
                                _("Go to the home page"));
     g_signal_connect(G_OBJECT(toolitem), "clicked",
                     G_CALLBACK(tg_gui_cb_home), NULL);
     gtk_toolbar_insert(GTK_TOOLBAR(toolbar), toolitem, -1);
 
-    toolitem = gtk_toggle_tool_button_new_from_stock(GTK_STOCK_MEDIA_PLAY);
+    toolitem = gtk_toggle_tool_button_new();
+    gtk_tool_button_set_label(GTK_TOOL_BUTTON(toolitem), _("_Play"));
+    gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(toolitem),
+                                 "media-playback-start");
     gtk_widget_set_tooltip_text(GTK_WIDGET(toolitem), "Toggles auto-paging");
     g_signal_connect(G_OBJECT(toolitem), "toggled",
                     G_CALLBACK(tg_gui_cb_toggle_paging), NULL);
@@ -657,8 +665,8 @@ tg_gui_new (GSettings *settings, gchar *startpage)
     GtkAccelGroup *accel_group;
     GBytes *menu_data;
     GtkWidget *menu_bar;
-    GtkWidget *progress_status_box;
     GtkWidget *status_frame;
+    GtkWidget *contents;
     GdkPixbuf *pixbuf;
     GError *error = NULL;
 
@@ -671,8 +679,8 @@ tg_gui_new (GSettings *settings, gchar *startpage)
     gtk_window_set_resizable (GTK_WINDOW (gui->window), FALSE);
     gui->accel_group = gtk_accel_group_new ();
     gtk_window_add_accel_group (GTK_WINDOW (gui->window), gui->accel_group);
-    gui->vbox = gtk_vbox_new (FALSE, 0);
-    gtk_container_add (GTK_CONTAINER (gui->window), gui->vbox);
+    gui->grid = gtk_grid_new ();
+    gtk_container_add (GTK_CONTAINER (gui->window), gui->grid);
 
     gtk_widget_realize (GTK_WIDGET (gui->window));
 
@@ -704,8 +712,8 @@ tg_gui_new (GSettings *settings, gchar *startpage)
     g_bytes_unref (menu_data);
 
     menu_bar = gtk_ui_manager_get_widget (ui_manager, "/MenuBar");
-    gtk_box_pack_start (GTK_BOX (gui->vbox), menu_bar, FALSE, FALSE, 0);
-    gtk_box_pack_start (GTK_BOX (gui->vbox), toolbar, FALSE, FALSE, 0);
+    gtk_grid_attach (GTK_GRID (gui->grid), menu_bar, 0, 0, 2, 1);
+    gtk_grid_attach (GTK_GRID (gui->grid), toolbar, 0, 1, 2, 1);
 
     gui->channel_menu = gtk_menu_item_get_submenu (
        GTK_MENU_ITEM (gtk_ui_manager_get_widget (ui_manager,
@@ -734,22 +742,23 @@ tg_gui_new (GSettings *settings, gchar *startpage)
                     G_SETTINGS_BIND_DEFAULT);
 
     /* all the contents */
-    gtk_box_pack_start (GTK_BOX (gui->vbox), tg_view_get_widget (currentview),
-                       TRUE, TRUE, 0);
+    contents = tg_view_get_widget (currentview);
+    gtk_widget_set_hexpand (contents, TRUE);
+    gtk_widget_set_halign (contents, GTK_ALIGN_FILL);
+    gtk_widget_set_vexpand (contents, TRUE);
+    gtk_widget_set_valign (contents, GTK_ALIGN_FILL);
+    gtk_grid_attach (GTK_GRID (gui->grid), contents, 0, 2, 2, 1);
 
     /* the progress and status bars */
-    progress_status_box = gtk_hbox_new (FALSE, 4);
     gui->progress_bar = gtk_progress_bar_new ();
-    gtk_box_pack_start (GTK_BOX (progress_status_box), gui->progress_bar,
-                       FALSE, FALSE, 0);
+    gtk_grid_attach (GTK_GRID (gui->grid), gui->progress_bar, 0, 3, 1, 1);
     status_frame = gtk_frame_new (NULL);
     gtk_frame_set_shadow_type (GTK_FRAME (status_frame), GTK_SHADOW_IN);
     gui->status_bar = gtk_statusbar_new ();
     gtk_container_add (GTK_CONTAINER (status_frame), gui->status_bar);
-    gtk_box_pack_start (GTK_BOX (progress_status_box), status_frame,
-                       TRUE, TRUE, 0);
-    gtk_box_pack_end (GTK_BOX (gui->vbox), progress_status_box,
-                     FALSE, FALSE, 0);
+    gtk_widget_set_hexpand (status_frame, TRUE);
+    gtk_widget_set_halign (status_frame, GTK_ALIGN_FILL);
+    gtk_grid_attach (GTK_GRID (gui->grid), status_frame, 1, 3, 1, 1);
 
     g_signal_connect (G_OBJECT (gui->window), "delete-event",
                      G_CALLBACK (tg_gui_cb_quit), NULL);
@@ -1035,7 +1044,7 @@ tg_gui_keyboard_timer (gpointer g)
 gint 
 tg_cb_keypress (GtkWidget *widget, GdkEventKey *event)
 {
-    if (event->keyval == GDK_KP_Enter) {
+    if (event->keyval == GDK_KEY_KP_Enter) {
        tg_gui_cb_goto_page(NULL, NULL);
        tg_gui_update_entry(currentview->page_nr, currentview->subpage_nr);
        return 0;
diff --git a/src/pixpack.c b/src/pixpack.c
index 36fbc53..cbf1002 100644
--- a/src/pixpack.c
+++ b/src/pixpack.c
@@ -37,13 +37,11 @@ typedef struct _TgPixPackPrivate TgPixPackPrivate;
 
 static void    tg_pixpack_class_init   (TgPixPackClass *klass);
 static void    tg_pixpack_init         (TgPixPack      *pixpack);
-static void    tg_pixpack_destroy      (GtkObject      *object);
+static void    tg_pixpack_destroy      (GtkWidget      *widget);
 static void    tg_pixpack_realize      (GtkWidget      *widget);
 static void    tg_pixpack_unrealize    (GtkWidget      *widget);
-static void     tg_pixpack_paint       (TgPixPack      *pixpack,
-                                        GdkRectangle   *area);
-static gint    tg_pixpack_expose       (GtkWidget      *widget,
-                                        GdkEventExpose *event);
+static gboolean        tg_pixpack_draw         (GtkWidget      *widget,
+                                        cairo_t        *cr);
 
 static GtkWidgetClass *parent_class = NULL;
 
@@ -74,16 +72,14 @@ tg_pixpack_get_type(void)
 static void
 tg_pixpack_class_init(TgPixPackClass *klass)
 {
-    GtkObjectClass *object_class = (GtkObjectClass*) klass;
     GtkWidgetClass *widget_class = (GtkWidgetClass*) klass;
 
     parent_class = g_type_class_peek_parent(klass);
 
-    object_class->destroy = tg_pixpack_destroy;
-
+    widget_class->destroy = tg_pixpack_destroy;
     widget_class->realize = tg_pixpack_realize;
     widget_class->unrealize = tg_pixpack_unrealize;
-    widget_class->expose_event = tg_pixpack_expose;
+    widget_class->draw = tg_pixpack_draw;
 }
 
 
@@ -111,15 +107,15 @@ tg_pixpack_new(void)
 
 
 static void
-tg_pixpack_destroy(GtkObject *object)
+tg_pixpack_destroy(GtkWidget *widget)
 {
     TgPixPack *pixpack;
     TgPixPackPrivate *private;
 
-    g_return_if_fail(object);
-    g_return_if_fail(TG_IS_PIXPACK(object));
+    g_return_if_fail(widget);
+    g_return_if_fail(TG_IS_PIXPACK(widget));
 
-    pixpack = TG_PIXPACK(object);
+    pixpack = TG_PIXPACK(widget);
     private = pixpack->private_data;
 
     if (private) {
@@ -129,8 +125,8 @@ tg_pixpack_destroy(GtkObject *object)
        g_clear_pointer(&pixpack->private_data, g_free);
     }
 
-    if (GTK_OBJECT_CLASS(parent_class)->destroy)
-       (*GTK_OBJECT_CLASS(parent_class)->destroy)(object);
+    if (GTK_WIDGET_CLASS(parent_class)->destroy)
+       (*GTK_WIDGET_CLASS(parent_class)->destroy)(widget);
 }
 
 static void
@@ -158,19 +154,14 @@ tg_pixpack_realize(GtkWidget *widget)
     attributes.width = allocation.width;
     attributes.wclass = GDK_INPUT_OUTPUT;
     attributes.visual = gtk_widget_get_visual(widget);
-    attributes.colormap = gtk_widget_get_colormap(widget);
     attributes.event_mask = gtk_widget_get_events(widget) | GDK_EXPOSURE_MASK;
 
-    attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
+    attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
 
     window = gdk_window_new(gtk_widget_get_parent_window(widget),
                            &attributes, attributes_mask);
     gtk_widget_set_window(widget, window);
     gdk_window_set_user_data(window, widget);
-
-    gtk_widget_style_attach(widget);
-    gtk_style_set_background(gtk_widget_get_style(widget), window,
-                            GTK_STATE_NORMAL);
 }
 
 
@@ -194,46 +185,36 @@ tg_pixpack_unrealize(GtkWidget *widget)
 }
 
 
-static void
-tg_pixpack_paint(TgPixPack* pixpack, GdkRectangle *area)
+static gboolean
+tg_pixpack_draw(GtkWidget *widget, cairo_t *cr)
 {
-    GtkWidget *widget;
+    TgPixPack *pixpack;
     TgPixPackPrivate *private;
-    GdkWindow *window;
-    cairo_t *cr;
+    gint width, height;
 
-    g_return_if_fail(pixpack != NULL);
-    g_return_if_fail(TG_IS_PIXPACK(pixpack));
-    g_return_if_fail(pixpack->private_data != NULL);
+    g_return_val_if_fail(widget != NULL, FALSE);
+    g_return_val_if_fail(TG_IS_PIXPACK(widget), FALSE);
 
-    private = pixpack->private_data;
+    pixpack = TG_PIXPACK(widget);
 
-    widget = GTK_WIDGET(pixpack);
-    if (!gtk_widget_is_drawable(widget))
-       return;
+    g_return_val_if_fail(pixpack->private_data != NULL, FALSE);
 
-    window = gtk_widget_get_window(widget);
-    gdk_window_clear_area(window, area->x, area->y, area->width, area->height);
+    private = pixpack->private_data;
 
     if (NULL == private->pixbuf)
-       return;
+       return FALSE;
+
+    width = gtk_widget_get_allocated_width(widget);
+    height = gtk_widget_get_allocated_height(widget);
 
-    cr = gdk_cairo_create(GDK_DRAWABLE(window));
-    gdk_cairo_set_source_pixbuf(cr, private->pixbuf, area->x, area->y);
-    gdk_cairo_rectangle(cr, area);
-    cairo_clip(cr);
+    cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
+    cairo_fill(cr);
+    gdk_cairo_set_source_pixbuf(cr, private->pixbuf, 0, 0);
     cairo_scale(cr,
-               area->width / gdk_pixbuf_get_width(private->pixbuf),
-               area->height / gdk_pixbuf_get_height(private->pixbuf));
+               width / gdk_pixbuf_get_width(private->pixbuf),
+               height / gdk_pixbuf_get_height(private->pixbuf));
     cairo_paint(cr);
-    cairo_destroy(cr);
-}
-
 
-static gboolean
-tg_pixpack_expose(GtkWidget *widget, GdkEventExpose *event)
-{
-    tg_pixpack_paint(TG_PIXPACK (widget), &event->area);
     return TRUE;
 }
 
diff --git a/src/prefs.c b/src/prefs.c
index 5839738..cb04542 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -95,7 +95,7 @@ static gboolean
 tg_prefs_edit_channel(TgChannel *orig)
 {
     GSettings *settings;
-    GtkWidget *dialog, *table, *label, *name, *page, *subpage, *desc, *country, *frame;
+    GtkWidget *dialog, *grid, *label, *name, *page, *subpage, *desc, *country, *frame;
     gint reply;
     gboolean changed = FALSE;
 
@@ -108,51 +108,52 @@ tg_prefs_edit_channel(TgChannel *orig)
        _("New/Edit Channel"),
        GTK_WINDOW(prefs_window->dialog),
        GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
-       GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
-       GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
+       _("_OK"), GTK_RESPONSE_ACCEPT,
+       _("_Cancel"), GTK_RESPONSE_REJECT,
        NULL);
 
-    table = gtk_table_new(5,2, FALSE);
-    gtk_table_set_row_spacings(GTK_TABLE(table), 5);
-    gtk_table_set_col_spacings(GTK_TABLE(table), 5);
+    grid = gtk_grid_new();
+    gtk_grid_set_row_homogeneous(GTK_GRID(grid), TRUE);
+    gtk_grid_set_row_spacing(GTK_GRID(grid), 5);
+    gtk_grid_set_column_spacing(GTK_GRID(grid), 5);
 
     label = gtk_label_new(_("Name"));
-    gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
+    g_object_set(G_OBJECT(label), "xalign", 1.0, "yalign", 0.5, NULL);
     name = gtk_entry_new();
     g_settings_bind(settings, "name", name, "text", G_SETTINGS_BIND_DEFAULT);
-    gtk_table_attach_defaults(GTK_TABLE(table), label, 0,1, 0,1);
-    gtk_table_attach_defaults(GTK_TABLE(table), name, 1,2, 0,1);
+    gtk_grid_attach(GTK_GRID(grid), label, 0, 0, 1, 1);
+    gtk_grid_attach(GTK_GRID(grid), name, 1, 0, 1, 1);
 
     label = gtk_label_new(_("Description"));
-    gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
+    g_object_set(G_OBJECT(label), "xalign", 1.0, "yalign", 0.5, NULL);
     desc = gtk_entry_new();
     g_settings_bind(settings, "description", desc, "text", G_SETTINGS_BIND_DEFAULT);
-    gtk_table_attach_defaults(GTK_TABLE(table), label, 0,1, 1,2);
-    gtk_table_attach_defaults(GTK_TABLE(table), desc,  1,2, 1,2);
+    gtk_grid_attach(GTK_GRID(grid), label, 0, 1, 1, 1);
+    gtk_grid_attach(GTK_GRID(grid), desc, 1, 1, 1, 1);
 
     label = gtk_label_new(_("Page url"));
-    gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
+    g_object_set(G_OBJECT(label), "xalign", 1.0, "yalign", 0.5, NULL);
     page = gtk_entry_new();
     g_settings_bind(settings, "page-url", page, "text", G_SETTINGS_BIND_DEFAULT);
-    gtk_table_attach_defaults(GTK_TABLE(table), label, 0,1, 2,3);
-    gtk_table_attach_defaults(GTK_TABLE(table), page,  1,2, 2,3);
+    gtk_grid_attach(GTK_GRID(grid), label, 0, 2, 1, 1);
+    gtk_grid_attach(GTK_GRID(grid), page, 1, 2, 1, 1);
 
     label = gtk_label_new(_("Subpage url"));
-    gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
+    g_object_set(G_OBJECT(label), "xalign", 1.0, "yalign", 0.5, NULL);
     subpage = gtk_entry_new();
     g_settings_bind(settings, "subpage-url", subpage, "text", G_SETTINGS_BIND_DEFAULT);
-    gtk_table_attach_defaults(GTK_TABLE(table), label, 0,1,    3,4);
-    gtk_table_attach_defaults(GTK_TABLE(table), subpage,  1,2, 3,4);
+    gtk_grid_attach(GTK_GRID(grid), label, 0, 3, 1, 1);
+    gtk_grid_attach(GTK_GRID(grid), subpage, 1, 3, 1, 1);
 
     label = gtk_label_new(_("Country"));
-    gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
+    g_object_set(G_OBJECT(label), "xalign", 1.0, "yalign", 0.5, NULL);
     country = gtk_entry_new();
     g_settings_bind(settings, "country", country, "text", G_SETTINGS_BIND_DEFAULT);
-    gtk_table_attach_defaults(GTK_TABLE(table), label, 0,1, 4,5);
-    gtk_table_attach_defaults(GTK_TABLE(table), country,  1,2, 4,5);
+    gtk_grid_attach(GTK_GRID(grid), label, 0, 4, 1, 1);
+    gtk_grid_attach(GTK_GRID(grid), country, 1, 4, 1, 1);
 
     frame = gtk_frame_new(_("Channel Information"));
-    gtk_container_add(GTK_CONTAINER(frame), table);
+    gtk_container_add(GTK_CONTAINER(frame), grid);
 
     gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), frame);
 
@@ -376,14 +377,14 @@ tg_prefs_channel_delete_cb(void)
 static GtkWidget *
 tg_prefs_construct_misc_page(void)
 {
-    GtkWidget *table, *frame, *label, *entry;
+    GtkWidget *grid, *frame, *label, *entry;
     GtkAdjustment *adj;
 
     g_assert(prefs_window != NULL);
 
-    table = gtk_table_new(2,2, FALSE);
-    gtk_table_set_row_spacings(GTK_TABLE(table), 5);
-    gtk_table_set_col_spacings(GTK_TABLE(table), 5);
+    grid = gtk_grid_new();
+    gtk_grid_set_row_spacing(GTK_GRID(grid), 5);
+    gtk_grid_set_column_spacing(GTK_GRID(grid), 5);
 
     label = gtk_label_new(_("Paging interval"));
     gtk_widget_set_tooltip_text(label, _("Specifies the interval for the auto-pager, in milliseconds."));
@@ -391,16 +392,16 @@ tg_prefs_construct_misc_page(void)
     adj = GTK_ADJUSTMENT(gtk_adjustment_new(8000.0, 1000.0, 60000.0, 1000.0, 10.0, 0.0));
     entry = gtk_spin_button_new(adj, 0.5, 0);
 
-    gtk_table_attach_defaults(GTK_TABLE(table), label, 0,1, 0,1);
-    gtk_table_attach_defaults(GTK_TABLE(table), entry, 1,2, 0,1);
+    gtk_grid_attach(GTK_GRID(grid), label, 0, 0, 1, 1);
+    gtk_grid_attach(GTK_GRID(grid), entry, 1, 0, 1, 1);
 
     g_settings_bind(prefs_window->settings, "paging-interval", entry, "value", G_SETTINGS_BIND_DEFAULT);
 
     frame = gtk_frame_new(_("Miscellaneous"));
 
-    gtk_container_set_border_width( GTK_CONTAINER(frame), 5);
-    gtk_container_set_border_width( GTK_CONTAINER(table), 5);
-    gtk_container_add( GTK_CONTAINER(frame), table);
+    gtk_container_set_border_width(GTK_CONTAINER(frame), 5);
+    gtk_container_set_border_width(GTK_CONTAINER(grid), 5);
+    gtk_container_add(GTK_CONTAINER(frame), grid);
 
     return frame;
 }
@@ -408,15 +409,14 @@ tg_prefs_construct_misc_page(void)
 static GtkWidget *
 tg_prefs_construct_channels_page()
 {
-    GtkWidget *hbox, *vbox, *btn;
+    GtkWidget *grid, *button_grid, *btn;
     GtkTreeViewColumn *country_column, *name_column;
     GtkTreeSelection *selection;
 
     g_assert(prefs_window != NULL);
 
-    hbox = gtk_hbox_new(FALSE, 0);
-
-    vbox = gtk_vbox_new(FALSE, 0);
+    grid = gtk_grid_new();
+    gtk_grid_set_column_spacing(GTK_GRID(grid), 10);
 
     /* the list */
     prefs_window->channel_store = gtk_list_store_new(
@@ -434,14 +434,15 @@ tg_prefs_construct_channels_page()
     gtk_tree_view_column_set_min_width(name_column, 200);
     gtk_tree_view_append_column(
        GTK_TREE_VIEW(prefs_window->channel_view), name_column);
-    gtk_box_pack_start(GTK_BOX(vbox), prefs_window->channel_view, TRUE, TRUE, 0);
+    gtk_widget_set_hexpand(prefs_window->channel_view, TRUE);
+    gtk_widget_set_halign(prefs_window->channel_view, GTK_ALIGN_FILL);
+    gtk_widget_set_vexpand(prefs_window->channel_view, TRUE);
+    gtk_widget_set_valign(prefs_window->channel_view, GTK_ALIGN_FILL);
+    gtk_grid_attach(GTK_GRID(grid), prefs_window->channel_view, 0, 0, 1, 1);
 
     /* label for descriptions and stuff */
     prefs_window->channel_label = gtk_label_new("");
-    gtk_container_set_border_width( GTK_CONTAINER(vbox), 10);
-    gtk_box_pack_start(GTK_BOX(vbox), prefs_window->channel_label, TRUE, TRUE, 0);
-
-    gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE , 0);
+    gtk_grid_attach(GTK_GRID(grid), prefs_window->channel_label, 0, 1, 1, 1);
 
     /* fill channel list */
     tg_prefs_fill_channel_list();
@@ -453,35 +454,39 @@ tg_prefs_construct_channels_page()
                     G_CALLBACK(tg_prefs_channel_selection_changed_cb),
                     NULL);
 
-    vbox = gtk_vbox_new(TRUE, 0);
-    
+    button_grid = gtk_grid_new();
+    gtk_orientable_set_orientation(GTK_ORIENTABLE(button_grid),
+                                  GTK_ORIENTATION_VERTICAL);
+    gtk_grid_set_row_homogeneous(GTK_GRID(button_grid), TRUE);
+    gtk_grid_set_row_spacing(GTK_GRID(button_grid), 4);
+
     /* move up button */
     btn = gtk_button_new_with_label(_("Move up"));
-    gtk_box_pack_start(GTK_BOX(vbox), btn, FALSE, FALSE, 2);
+    gtk_container_add(GTK_CONTAINER(button_grid), btn);
     g_signal_connect(G_OBJECT(btn), "clicked", G_CALLBACK(tg_prefs_channel_move_up_cb), NULL);
     /* move down button */
     btn = gtk_button_new_with_label(_("Move down"));
-    gtk_box_pack_start(GTK_BOX(vbox), btn, FALSE, FALSE, 2);
+    gtk_container_add(GTK_CONTAINER(button_grid), btn);
     g_signal_connect(G_OBJECT(btn), "clicked", G_CALLBACK(tg_prefs_channel_move_down_cb), NULL);
     /* add button */
     btn = gtk_button_new_with_label(_("Add..."));
-    gtk_box_pack_start(GTK_BOX(vbox), btn, FALSE, FALSE, 2);
+    gtk_container_add(GTK_CONTAINER(button_grid), btn);
     g_signal_connect(G_OBJECT(btn), "clicked", G_CALLBACK(tg_prefs_channel_add_cb), NULL);
 
     /* delete button */
     btn = gtk_button_new_with_label(_("Delete"));
-    gtk_box_pack_start(GTK_BOX(vbox), btn, FALSE, FALSE, 2);
+    gtk_container_add(GTK_CONTAINER(button_grid), btn);
     g_signal_connect(G_OBJECT(btn), "clicked", G_CALLBACK(tg_prefs_channel_delete_cb), NULL);
 
-    /* edit buton */
+    /* edit button */
     btn = gtk_button_new_with_label(_("Edit"));
-    gtk_box_pack_start(GTK_BOX(vbox), btn, FALSE, FALSE, 2);
+    gtk_container_add(GTK_CONTAINER(button_grid), btn);
     g_signal_connect(G_OBJECT(btn), "clicked", G_CALLBACK(tg_prefs_channel_edit_cb), NULL);
 
-    gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
-    
-    gtk_container_set_border_width( GTK_CONTAINER(hbox), 5);
-    return hbox;
+    gtk_grid_attach(GTK_GRID(grid), button_grid, 1, 0, 1, 2);
+
+    gtk_container_set_border_width(GTK_CONTAINER(grid), 5);
+    return grid;
 }
 
 void
@@ -500,8 +505,8 @@ tg_prefs_show(GtkWindow *parent, GCallback close_cb)
        prefs_window->dialog = gtk_dialog_new_with_buttons(
            _("TeleGNOME: Preferences"), parent,
            GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
-           GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
-           GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
+           _("_OK"), GTK_RESPONSE_ACCEPT,
+           _("_Cancel"), GTK_RESPONSE_REJECT,
            NULL);
        content_area = gtk_dialog_get_content_area(
            GTK_DIALOG(prefs_window->dialog));
diff --git a/src/view.c b/src/view.c
index aba37ee..9e225fd 100644
--- a/src/view.c
+++ b/src/view.c
@@ -41,13 +41,9 @@ tg_view_new(void)
     
     v = g_malloc(sizeof(TgView));
 
-    v->box = gtk_vbox_new(TRUE, 0);
-    
     v->pixpack = tg_pixpack_new();
     tg_pixpack_set_autosize(TG_PIXPACK(v->pixpack), TRUE);
 
-    gtk_box_pack_start(GTK_BOX(v->box), v->pixpack, TRUE, TRUE, 0);
-    
     v->zoom_factor = 1.0;
 
     v->channel = NULL;
@@ -150,15 +146,13 @@ tg_view_update_page(TgView *view, int *major_nr, int *minor_nr)
 GtkWidget *
 tg_view_get_widget(TgView *view)
 {
-    g_object_ref(view->box);
-    return view->box;
+    return g_object_ref(view->pixpack);
 }
 
 void 
 tg_view_free(TgView *view)
 {
     /* clean up */
-    g_clear_object(&view->box);
+    g_clear_object(&view->pixpack);
     g_free(view);
 }
-
diff --git a/src/view.h b/src/view.h
index 6404369..3832906 100644
--- a/src/view.h
+++ b/src/view.h
@@ -42,9 +42,6 @@ typedef struct _TgView {
 
     int page_nr;
     int subpage_nr;
-
-    /* the box */
-    GtkWidget *box;
 } TgView;
     
 TgView *tg_view_new(void);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]