[frogr] Added a toolbar of dummy items



commit 31ce79db0e4174d4821c0eafa9c1a42f50a253cc
Author: Mario Sanchez Prada <msanchez gnome org>
Date:   Thu Dec 19 07:28:02 2013 +0000

    Added a toolbar of dummy items

 data/gtkbuilder/frogr-main-view.xml |   11 +++++++++
 src/frogr-main-view.c               |   39 ++++++++++++++++++++++++++++++----
 2 files changed, 45 insertions(+), 5 deletions(-)
---
diff --git a/data/gtkbuilder/frogr-main-view.xml b/data/gtkbuilder/frogr-main-view.xml
index 1fc0448..d221dcd 100644
--- a/data/gtkbuilder/frogr-main-view.xml
+++ b/data/gtkbuilder/frogr-main-view.xml
@@ -6,6 +6,17 @@
     <property name="visible">True</property>
     <property name="can_focus">False</property>
     <child>
+      <object class="GtkToolbar" id="toolbar">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+        <property name="position">1</property>
+      </packing>
+    </child>
+    <child>
       <object class="GtkScrolledWindow" id="scrolled_window">
         <property name="visible">True</property>
         <property name="can_focus">True</property>
diff --git a/src/frogr-main-view.c b/src/frogr-main-view.c
index e5c90a2..ccd412d 100644
--- a/src/frogr-main-view.c
+++ b/src/frogr-main-view.c
@@ -130,6 +130,7 @@ enum {
 /* Prototypes */
 
 static void _initialize_ui (FrogrMainView *self);
+static GtkToolItem *_create_toolbar_item (const gchar *icon_name, const gchar *label, const gchar 
*tooltip_text);
 static gboolean _maybe_show_auth_dialog_on_idle (FrogrMainView *self);
 
 static void _update_project_path (FrogrMainView *self, const gchar *path);
@@ -311,7 +312,8 @@ _initialize_ui (FrogrMainView *self)
   GtkWidget *progress_vbox;
   GtkWidget *progress_bar;
   GtkWidget *progress_label;
-  /* GtkWidget *toolbar; */
+  GtkWidget *toolbar;
+  GtkToolItem *toolbar_item;
   const gchar *icons_path = NULL;
   gchar *full_path = NULL;
   GList *icons = NULL;
@@ -386,10 +388,24 @@ _initialize_ui (FrogrMainView *self)
                                G_MENU_MODEL (gtk_builder_get_object (builder, "menu-bar")));
   gtk_application_window_set_show_menubar (GTK_APPLICATION_WINDOW (self), TRUE);
 
-  /* TODO: Toolbar */
-  /* toolbar = GTK_WIDGET (gtk_builder_get_object (builder, "toolbar")); */
-  /* gtk_style_context_add_class (gtk_widget_get_style_context (toolbar), */
-  /*                              GTK_STYLE_CLASS_PRIMARY_TOOLBAR); */
+  /* Toolbar */
+  toolbar = GTK_WIDGET (gtk_builder_get_object (builder, "toolbar"));
+  toolbar_item = _create_toolbar_item ("gtk-open", _("Open"), _("Open Existing Project"));
+  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolbar_item, 0);
+  toolbar_item = _create_toolbar_item ("gtk-save", _("Save"), _("Save Current Project"));
+  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolbar_item, 1);
+  toolbar_item = gtk_separator_tool_item_new ();
+  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolbar_item, 2);
+  toolbar_item = _create_toolbar_item ("gtk-add", _("Add"), _("Add Elements"));
+  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolbar_item, 3);
+  toolbar_item = _create_toolbar_item ("gtk-remove", _("Remove"), _("Remove Elements"));
+  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolbar_item, 4);
+  toolbar_item = gtk_separator_tool_item_new ();
+  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolbar_item, 5);
+  toolbar_item = _create_toolbar_item ("gtk-go-up", _("Upload"), _("Upload All"));
+  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolbar_item, 6);
+  gtk_style_context_add_class (gtk_widget_get_style_context (toolbar),
+                               GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
 
   icon_view = GTK_WIDGET (gtk_builder_get_object (builder, "icon_view"));
   priv->icon_view = icon_view;
@@ -531,6 +547,19 @@ _initialize_ui (FrogrMainView *self)
   gtk_widget_show_all (GTK_WIDGET (self));
 }
 
+static GtkToolItem *
+_create_toolbar_item (const gchar *icon_name, const gchar *label, const gchar *tooltip_text)
+{
+  GtkWidget *widget = NULL;
+  GtkToolItem *toolbar_item = NULL;
+
+  widget = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_SMALL_TOOLBAR);
+  toolbar_item = gtk_tool_button_new (widget, label);
+  gtk_tool_item_set_tooltip_text (toolbar_item, tooltip_text);
+
+  return toolbar_item;
+}
+
 static gboolean
 _maybe_show_auth_dialog_on_idle (FrogrMainView *self)
 {


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