fix searching for open files by pulling the fixes from the system-monitor git repo

This commit is contained in:
robert 2014-07-12 20:03:09 +00:00
parent 83b6a9f166
commit d10465ce9f
3 changed files with 352 additions and 1 deletions

View File

@ -1,10 +1,12 @@
# $OpenBSD: Makefile,v 1.55 2014/05/13 08:54:43 jasper Exp $
# $OpenBSD: Makefile,v 1.56 2014/07/12 20:03:09 robert Exp $
COMMENT= sytem monitor for GNOME
GNOME_PROJECT= gnome-system-monitor
GNOME_VERSION= 3.12.2
REVISION= 0
CATEGORIES= sysutils
# GPLv2

View File

@ -0,0 +1,230 @@
$OpenBSD: patch-data_lsof_ui,v 1.1 2014/07/12 20:03:09 robert Exp $
--- data/lsof.ui.orig Sat Jul 12 22:01:53 2014
+++ data/lsof.ui Sat Jul 12 22:02:00 2014
@@ -3,60 +3,42 @@
<!-- 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="border_width">0</property>
<property name="title" translatable="yes" context="Window title for 'Search for Open Files' dialog">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">
+ <child >
+ <object class="GtkBox" id="mainbox">
<property name="visible">True</property>
+ <property name="border_width">0</property>
<property name="can_focus">False</property>
+ <property name="spacing">0</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">
+ <object class="GtkBox" id="search_box">
<property name="visible">True</property>
+ <property name="border_width">6</property>
<property name="can_focus">False</property>
- <property name="row_spacing">6</property>
- <property name="column_spacing">6</property>
+ <property name="orientation">vertical</property>
<child>
- <object class="GtkLabel" id="label">
+ <object class="GtkSearchEntry" id="entry">
<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" translatable="yes">_Find</property>
- <property name="use_underline">True</property>
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
+ <property name="width_request">300</property>
<property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_action_appearance">False</property>
- <property name="use_stock">False</property>
+ <property name="hexpand">True</property>
+ <property name="invisible_char">•</property>
+ <property name="placeholder-text" translatable="yes">Filter files by name</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>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="case_button">
- <property name="label" translatable="yes">Case insensitive matching</property>
+ <property name="label" translatable="yes">Case insensitive</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -66,127 +48,19 @@
<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>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">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>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkGrid" id="results_box">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hexpand">True</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="halign">end</property>
- <property name="hexpand">True</property>
- <property name="use_underline">True</property>
- <property name="justify">right</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" translatable="yes">_Close</property>
- <property name="use_underline">True</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">False</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>
@@ -198,10 +72,10 @@
</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>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
</packing>
</child>
</object>

View File

@ -0,0 +1,119 @@
$OpenBSD: patch-src_lsof_cpp,v 1.3 2014/07/12 20:03:09 robert Exp $
--- src/lsof.cpp.orig Sat Jul 12 22:02:07 2014
+++ src/lsof.cpp Sat Jul 12 22:02:18 2014
@@ -103,20 +103,6 @@ namespace
}
- void clear_results()
- {
- gtk_list_store_clear(this->model);
- gtk_label_set_text(this->count, "");
- }
-
-
- void clear()
- {
- this->clear_results();
- gtk_entry_set_text(this->entry, "");
- }
-
-
void display_regex_error(const Glib::RegexError& error)
{
char * msg = g_strdup_printf ("<b>%s</b>\n%s\n%s",
@@ -137,8 +123,14 @@ namespace
void update_count(unsigned count)
{
- string s = static_cast<std::ostringstream&>(std::ostringstream() << count).str();
- gtk_label_set_text(this->count, s.c_str());
+ gchar *title;
+ if (this->pattern().length() == 0) {
+ title = g_strdup_printf (ngettext("%d open file", "%d open files", count), count);
+ } else {
+ title = g_strdup_printf (ngettext("%d matching open file", "%d matching open files", count), count);
+ }
+ gtk_window_set_title(this->window, title);
+ g_free (title);
}
@@ -153,9 +145,7 @@ namespace
typedef std::set<string> MatchSet;
typedef MatchSet::const_iterator iterator;
- this->clear_results();
-
-
+ gtk_list_store_clear(this->model);
try {
Lsof lsof(this->pattern(), this->case_insensitive);
@@ -188,24 +178,12 @@ namespace
}
- static void search_button_clicked(GtkButton *, gpointer data)
+ static void search_changed(GtkSearchEntry *, gpointer data)
{
static_cast<GUI*>(data)->search();
}
- static void search_entry_activate(GtkEntry *, gpointer data)
- {
- static_cast<GUI*>(data)->search();
- }
-
-
- static void clear_button_clicked(GtkButton *, gpointer data)
- {
- static_cast<GUI*>(data)->clear();
- }
-
-
static void close_button_clicked(GtkButton *, gpointer data)
{
GUI *gui = static_cast<GUI*>(data);
@@ -308,12 +286,8 @@ void procman_lsof(GsmApplication *app)
gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(app->main_window));
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_WIDGET (gtk_builder_get_object (builder, "scrolled"));
@@ -325,16 +299,10 @@ void procman_lsof(GsmApplication *app)
gui->model = model;
gui->window = GTK_WINDOW(dialog);
gui->entry = GTK_ENTRY(entry);
- gui->count = GTK_LABEL(count_label);
+ gui->case_insensitive = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (case_button));
- g_signal_connect(G_OBJECT(entry), "activate",
- G_CALLBACK(GUI::search_entry_activate), gui);
- g_signal_connect(G_OBJECT(clear_button), "clicked",
- G_CALLBACK(GUI::clear_button_clicked), gui);
- g_signal_connect(G_OBJECT(search_button), "clicked",
- G_CALLBACK(GUI::search_button_clicked), gui);
- g_signal_connect(G_OBJECT(close_button), "clicked",
- G_CALLBACK(GUI::close_button_clicked), gui);
+ g_signal_connect(G_OBJECT(entry), "search-changed",
+ G_CALLBACK(GUI::search_changed), gui);
g_signal_connect(G_OBJECT(case_button), "toggled",
G_CALLBACK(GUI::case_button_toggled), gui);
g_signal_connect(G_OBJECT(dialog), "delete-event",
@@ -343,6 +311,7 @@ void procman_lsof(GsmApplication *app)
gtk_builder_connect_signals (builder, NULL);
gtk_widget_show_all(dialog);
+ gui->search ();
g_object_unref (G_OBJECT (builder));
}