[gnome-system-monitor/migrateui] Migrated the open files dialog to an UI file



commit e2d3a720238ee0c09d8d3b26ad6c04335eb1bc5b
Author: Robert Roth <robert roth off gmail com>
Date:   Sat Jul 21 23:26:42 2012 +0300

    Migrated the open files dialog to an UI file

 Makefile.am       |    3 +-
 data/openfiles.ui |  100 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/openfiles.cpp |   38 +++++---------------
 3 files changed, 112 insertions(+), 29 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 048ba86..baa5ab7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -6,7 +6,8 @@ SUBDIRS = pixmaps po src help
 uidir = $(pkgdatadir)
 ui_DATA = data/preferences.ui \
           data/renice.ui \
-          data/lsof.ui
+          data/lsof.ui \
+          data/openfiles.ui
 
 EXTRA_DIST = \
 	$(ui_DATA) \
diff --git a/data/openfiles.ui b/data/openfiles.ui
new file mode 100644
index 0000000..572aea2
--- /dev/null
+++ b/data/openfiles.ui
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.0 -->
+  <object class="GtkDialog" id="openfiles_dialog">
+    <property name="can_focus">False</property>
+    <property name="border_width">5</property>
+    <property name="title" translatable="yes">Open Files</property>
+    <property name="default_width">575</property>
+    <property name="default_height">400</property>
+    <property name="destroy_with_parent">True</property>
+    <property name="type_hint">dialog</property>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="dialog_content">
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="action_area">
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="close_button">
+                <property name="label">gtk-close</property>
+                <property name="use_action_appearance">False</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkGrid" id="content_grid">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="border_width">5</property>
+            <property name="row_spacing">6</property>
+            <property name="column_spacing">6</property>
+            <child>
+              <object class="GtkScrolledWindow" id="scrolled">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="vexpand">True</property>
+                <property name="shadow_type">in</property>
+                <child>
+                  <placeholder/>
+                </child>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">1</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkGrid" id="cmd_grid">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="hexpand">True</property>
+                <property name="row_spacing">12</property>
+                <property name="column_spacing">12</property>
+                <child>
+                  <placeholder/>
+                </child>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">0</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-7">close_button</action-widget>
+    </action-widgets>
+  </object>
+</interface>
diff --git a/src/openfiles.cpp b/src/openfiles.cpp
index 3b6fcab..32cd498 100644
--- a/src/openfiles.cpp
+++ b/src/openfiles.cpp
@@ -320,8 +320,7 @@ create_single_openfiles_dialog (GtkTreeModel *model, GtkTreePath *path,
 {
     ProcData *procdata = static_cast<ProcData*>(data);
     GtkWidget *openfilesdialog;
-    GtkWidget *dialog_vbox, *vbox;
-    GtkWidget *cmd_hbox;
+    GtkWidget *cmd_grid;
     GtkWidget *label;
     GtkWidget *scrolled;
     GtkWidget *tree;
@@ -333,24 +332,14 @@ create_single_openfiles_dialog (GtkTreeModel *model, GtkTreePath *path,
     if (!info)
         return;
 
-    openfilesdialog = gtk_dialog_new_with_buttons (_("Open Files"), NULL,
-                                                   GTK_DIALOG_DESTROY_WITH_PARENT,
-                                                   GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
-                                                   NULL);
-    gtk_window_set_resizable (GTK_WINDOW (openfilesdialog), TRUE);
-    gtk_window_set_default_size (GTK_WINDOW (openfilesdialog), 575, 400);
-    gtk_container_set_border_width (GTK_CONTAINER (openfilesdialog), 5);
+    gchar* filename = g_build_filename (GSM_DATA_DIR, "openfiles.ui", NULL);
 
-    vbox = gtk_dialog_get_content_area (GTK_DIALOG (openfilesdialog));
-    gtk_box_set_spacing (GTK_BOX (vbox), 2);
-    gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+    GtkBuilder *builder = gtk_builder_new();
+    gtk_builder_add_from_file (builder, filename, NULL);
 
-    dialog_vbox = gtk_vbox_new (FALSE, 6);
-    gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
-    gtk_box_pack_start (GTK_BOX (vbox), dialog_vbox, TRUE, TRUE, 0);
+    openfilesdialog = GTK_WIDGET (gtk_builder_get_object (builder, "openfiles_dialog"));
 
-    cmd_hbox = gtk_hbox_new (FALSE, 12);
-    gtk_box_pack_start (GTK_BOX (dialog_vbox), cmd_hbox, FALSE, FALSE, 0);
+    cmd_grid = GTK_WIDGET (gtk_builder_get_object (builder, "cmd_grid"));
 
 
     label = procman_make_label_for_mmaps_or_ofiles (
@@ -358,27 +347,20 @@ create_single_openfiles_dialog (GtkTreeModel *model, GtkTreePath *path,
         info->name,
         info->pid);
 
-    gtk_box_pack_start (GTK_BOX (cmd_hbox),label, FALSE, FALSE, 0);
+    gtk_container_add (GTK_CONTAINER (cmd_grid), label);
 
-
-    scrolled = gtk_scrolled_window_new (NULL, NULL);
-    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
-                                    GTK_POLICY_AUTOMATIC,
-                                    GTK_POLICY_AUTOMATIC);
-    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
-                                         GTK_SHADOW_IN);
+    scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "scrolled"));
 
     tree = create_openfiles_tree (procdata);
     gtk_container_add (GTK_CONTAINER (scrolled), tree);
     g_object_set_data (G_OBJECT (tree), "selected_info", info);
     g_object_set_data (G_OBJECT (tree), "settings", procdata->settings);
 
-    gtk_box_pack_start (GTK_BOX (dialog_vbox), scrolled, TRUE, TRUE, 0);
-    gtk_widget_show_all (scrolled);
-
     g_signal_connect (G_OBJECT (openfilesdialog), "response",
                       G_CALLBACK (close_openfiles_dialog), tree);
 
+    gtk_builder_connect_signals (builder, NULL);
+
     gtk_widget_show_all (openfilesdialog);
 
     timer = g_timeout_add_seconds (5, openfiles_timer, tree);



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