[gnome-system-monitor] LSOF dialog migrated to UI file
- From: Chris KÃhl <chriskuehl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-system-monitor] LSOF dialog migrated to UI file
- Date: Sun, 29 Jul 2012 14:53:14 +0000 (UTC)
commit 341ef7d888159c7da4a9dbee19198815c03493c4
Author: Robert Roth <robert roth off gmail com>
Date: Sat Jul 21 21:28:09 2012 +0300
LSOF dialog migrated to UI file
Makefile.am | 3 +-
data/lsof.ui | 218 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/lsof.cpp | 82 ++++------------------
3 files changed, 235 insertions(+), 68 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 9ca636c..048ba86 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5,7 +5,8 @@ SUBDIRS = pixmaps po src help
uidir = $(pkgdatadir)
ui_DATA = data/preferences.ui \
- data/renice.ui
+ data/renice.ui \
+ data/lsof.ui
EXTRA_DIST = \
$(ui_DATA) \
diff --git a/data/lsof.ui b/data/lsof.ui
new file mode 100644
index 0000000..6400261
--- /dev/null
+++ b/data/lsof.ui
@@ -0,0 +1,218 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkWindow" id="lsof_dialog">
+ <property name="can_focus">False</property>
+ <property name="border_width">12</property>
+ <property name="title" translatable="yes">Search for Open Files</property>
+ <property name="default_width">575</property>
+ <property name="default_height">400</property>
+ <property name="destroy_with_parent">True</property>
+ <child>
+ <object class="GtkGrid" id="mainbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">6</property>
+ <child>
+ <object class="GtkGrid" id="header_grid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">6</property>
+ <child>
+ <object class="GtkImage" id="image">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-find</property>
+ <property name="icon-size">6</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0.51999998092651367</property>
+ <property name="label" translatable="yes">_Name contains:</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="search_button">
+ <property name="label">gtk-find</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="left_attach">3</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="case_button">
+ <property name="label" translatable="yes">Case insensitive matching</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="width">4</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="invisible_char">â</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="clear_button">
+ <property name="label" translatable="yes">C_lear</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_underline">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">4</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </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>
+ <child>
+ <object class="GtkGrid" id="results_box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="column_spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="results_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">S_earch results:</property>
+ <property name="use_underline">True</property>
+ </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>
+ <child>
+ <object class="GtkLabel" id="count_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </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="bottom_box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">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="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="left_attach">0</property>
+ <property name="top_attach">3</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolled">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">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">2</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/src/lsof.cpp b/src/lsof.cpp
index d7f461f..6e7490d 100644
--- a/src/lsof.cpp
+++ b/src/lsof.cpp
@@ -302,86 +302,33 @@ void procman_lsof(ProcData *procdata)
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
NULL); */
- dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(procdata->app));
- gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
- // gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
- gtk_window_set_title(GTK_WINDOW(dialog), _("Search for Open Files"));
-
- // g_signal_connect(G_OBJECT(dialog), "response",
- // G_CALLBACK(close_dialog), NULL);
- gtk_window_set_resizable(GTK_WINDOW(dialog), TRUE);
- gtk_window_set_default_size(GTK_WINDOW(dialog), 575, 400);
- gtk_container_set_border_width(GTK_CONTAINER(dialog), 12);
- GtkWidget *mainbox = gtk_vbox_new(FALSE, 12);
- gtk_container_add(GTK_CONTAINER(dialog), mainbox);
- gtk_box_set_spacing(GTK_BOX(mainbox), 6);
-
-
- // Label, entry and search button
-
- GtkWidget *hbox1 = gtk_hbox_new(FALSE, 12);
- gtk_box_pack_start(GTK_BOX(mainbox), hbox1, FALSE, FALSE, 0);
+ //dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gchar* filename = g_build_filename (GSM_DATA_DIR, "lsof.ui", NULL);
- GtkWidget *image = gtk_image_new_from_stock(GTK_STOCK_FIND, GTK_ICON_SIZE_DIALOG);
- gtk_box_pack_start(GTK_BOX(hbox1), image, FALSE, FALSE, 0);
+ GtkBuilder *builder = gtk_builder_new();
+ gtk_builder_add_from_file (builder, filename, NULL);
+ dialog = GTK_WIDGET (gtk_builder_get_object (builder, "lsof_dialog"));
- GtkWidget *vbox2 = gtk_vbox_new(FALSE, 12);
- gtk_box_pack_start(GTK_BOX(hbox1), vbox2, TRUE, TRUE, 0);
-
-
- GtkWidget *hbox = gtk_hbox_new(FALSE, 12);
- gtk_box_pack_start(GTK_BOX(vbox2), hbox, TRUE, TRUE, 0);
- GtkWidget *label = gtk_label_new_with_mnemonic(_("_Name contains:"));
- gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
- GtkWidget *entry = gtk_entry_new();
+ gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(procdata->app));
// entry = sexy_icon_entry_new();
// sexy_icon_entry_add_clear_button(SEXY_ICON_ENTRY(entry));
// GtkWidget *icon = gtk_image_new_from_stock(GTK_STOCK_FIND, GTK_ICON_SIZE_MENU);
// sexy_icon_entry_set_icon(SEXY_ICON_ENTRY(entry), SEXY_ICON_ENTRY_PRIMARY, GTK_IMAGE(icon));
- gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
- GtkWidget *search_button = gtk_button_new_from_stock(GTK_STOCK_FIND);
- gtk_box_pack_start(GTK_BOX(hbox), search_button, FALSE, FALSE, 0);
- GtkWidget *clear_button = gtk_button_new_from_stock(GTK_STOCK_CLEAR);
- /* The default accelerator collides with the default close accelerator. */
- gtk_button_set_label(GTK_BUTTON(clear_button), _("C_lear"));
- gtk_box_pack_start(GTK_BOX(hbox), clear_button, FALSE, FALSE, 0);
-
-
- GtkWidget *case_button = gtk_check_button_new_with_mnemonic(_("Case insensitive matching"));
- GtkWidget *hbox3 = gtk_hbox_new(FALSE, 12);
- gtk_box_pack_start(GTK_BOX(hbox3), case_button, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(vbox2), hbox3, FALSE, FALSE, 0);
-
-
- GtkWidget *results_box = gtk_hbox_new(FALSE, 12);
- gtk_box_pack_start(GTK_BOX(mainbox), results_box, FALSE, FALSE, 0);
- GtkWidget *results_label = gtk_label_new_with_mnemonic(_("S_earch results:"));
- gtk_box_pack_start(GTK_BOX(results_box), results_label, FALSE, FALSE, 0);
- GtkWidget *count_label = gtk_label_new(NULL);
- gtk_box_pack_end(GTK_BOX(results_box), count_label, FALSE, FALSE, 0);
-
-
+ GtkWidget *entry = GTK_WIDGET (gtk_builder_get_object (builder, "entry"));
+ GtkWidget *search_button = GTK_WIDGET (gtk_builder_get_object (builder, "search_button"));
+ GtkWidget *clear_button = GTK_WIDGET (gtk_builder_get_object (builder, "clear_button"));
+ GtkWidget *case_button = GTK_WIDGET (gtk_builder_get_object (builder, "case_button"));
+ GtkWidget *count_label = GTK_WIDGET (gtk_builder_get_object (builder, "count_label"));
+ GtkWidget *close_button = GTK_WIDGET (gtk_builder_get_object (builder, "close_button"));
// Scrolled TreeView
- GtkWidget *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);
- gtk_container_add(GTK_CONTAINER(scrolled), tree);
- gtk_box_pack_start(GTK_BOX(mainbox), scrolled, TRUE, TRUE, 0);
-
- GtkWidget *bottom_box = gtk_hbox_new(FALSE, 12);
- GtkWidget *close_button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
- gtk_box_pack_start(GTK_BOX(mainbox), bottom_box, FALSE, FALSE, 0);
- gtk_box_pack_end(GTK_BOX(bottom_box), close_button, FALSE, FALSE, 0);
+ GtkWidget *scrolled = GTK_WIDGET (gtk_builder_get_object (builder, "scrolled"));
+ gtk_container_add(GTK_CONTAINER(scrolled), tree);
GUI *gui = new GUI; // wil be deleted by the close button or delete-event
gui->procdata = procdata;
@@ -403,6 +350,7 @@ void procman_lsof(ProcData *procdata)
g_signal_connect(G_OBJECT(dialog), "delete-event",
G_CALLBACK(GUI::window_delete_event), gui);
+ gtk_builder_connect_signals (builder, NULL);
gtk_widget_show_all(dialog);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]