[Goodies-commits] r5792 - in xfce4-dict/trunk: lib panel-plugin
Enrico Troeger
enrico at xfce.org
Fri Oct 24 19:30:22 CEST 2008
Author: enrico
Date: 2008-10-24 17:30:22 +0000 (Fri, 24 Oct 2008)
New Revision: 5792
Modified:
xfce4-dict/trunk/lib/gui.c
xfce4-dict/trunk/panel-plugin/xfce4-dict-plugin.c
Log:
Fix auto clearing issues introduced in last commit.
Modified: xfce4-dict/trunk/lib/gui.c
===================================================================
--- xfce4-dict/trunk/lib/gui.c 2008-10-24 17:30:19 UTC (rev 5791)
+++ xfce4-dict/trunk/lib/gui.c 2008-10-24 17:30:22 UTC (rev 5792)
@@ -40,6 +40,7 @@
static gboolean hovering_over_link = FALSE;
static GdkCursor *hand_cursor = NULL;
static GdkCursor *regular_cursor = NULL;
+static gboolean entry_is_dirty = FALSE;
/* all textview_* functions are from the gtk-demo app to get links in the textview working */
@@ -252,6 +253,12 @@
}
+static void entry_changed_cb(GtkEditable *editable, DictData *dd)
+{
+ entry_is_dirty = TRUE;
+}
+
+
static void entry_button_clicked_cb(GtkButton *button, DictData *dd)
{
entry_activate_cb(NULL, dd);
@@ -261,11 +268,9 @@
static gboolean entry_button_press_cb(GtkWidget *widget, GdkEventButton *event, DictData *dd)
{
- static gboolean ran = FALSE;
-
- if (! ran)
+ if (! entry_is_dirty)
{
- ran = TRUE;
+ entry_is_dirty = TRUE;
if (event->button == 1)
gtk_entry_set_text(GTK_ENTRY(widget), "");
}
@@ -463,6 +468,7 @@
gtk_box_pack_start(GTK_BOX(label_box), dd->main_entry, TRUE, TRUE, 0);
g_signal_connect(dd->main_entry, "button-press-event", G_CALLBACK(entry_button_press_cb), dd);
g_signal_connect(dd->main_entry, "activate", G_CALLBACK(entry_activate_cb), dd);
+ g_signal_connect(dd->main_entry, "changed", G_CALLBACK(entry_changed_cb), dd);
g_signal_connect(dd->main_entry, "icon_released", G_CALLBACK(entry_icon_pressed_cb), dd);
update_search_button(dd, entry_box);
Modified: xfce4-dict/trunk/panel-plugin/xfce4-dict-plugin.c
===================================================================
--- xfce4-dict/trunk/panel-plugin/xfce4-dict-plugin.c 2008-10-24 17:30:19 UTC (rev 5791)
+++ xfce4-dict/trunk/panel-plugin/xfce4-dict-plugin.c 2008-10-24 17:30:22 UTC (rev 5792)
@@ -54,6 +54,8 @@
} DictPanelData;
+static gboolean entry_is_dirty = FALSE;
+
static GdkPixbuf *dict_plugin_load_and_scale(const guint8 *data, gint dstw, gint dsth)
{
GdkPixbuf *pb, *pb_scaled;
@@ -262,29 +264,6 @@
}
-static gboolean dict_plugin_panel_entry_buttonpress_cb(GtkWidget *entry, GdkEventButton *event, DictPanelData *dpd)
-{
- GtkWidget *toplevel;
- static gboolean ran = FALSE;
-
- if (! ran)
- {
- ran = TRUE;
- if (event->button == 1)
- gtk_entry_set_text(GTK_ENTRY(entry), "");
- }
-
- /* Determine toplevel parent widget */
- toplevel = gtk_widget_get_toplevel(entry);
-
- /* Grab entry focus if possible */
- if (event->button != 3 && toplevel && toplevel->window)
- xfce_panel_plugin_focus_widget(dpd->plugin, entry);
-
- return FALSE;
-}
-
-
static void dict_plugin_write_rc_file(XfcePanelPlugin *plugin, DictPanelData *dpd)
{
dict_write_rc_file(dpd->dd);
@@ -333,7 +312,7 @@
}
-static void dict_plugin_panel_entry_activate_cb(GtkEntry *entry, DictPanelData *dpd)
+static void entry_activate_cb(GtkEntry *entry, DictPanelData *dpd)
{
const gchar *entered_text = gtk_entry_get_text(GTK_ENTRY(dpd->dd->panel_entry));
@@ -350,7 +329,7 @@
if (pos == SEXY_ICON_ENTRY_PRIMARY)
{
- dict_plugin_panel_entry_activate_cb(NULL, dpd);
+ entry_activate_cb(NULL, dpd);
gtk_widget_grab_focus(dpd->dd->main_entry);
}
else if (pos == SEXY_ICON_ENTRY_SECONDARY)
@@ -363,6 +342,34 @@
}
+static gboolean entry_buttonpress_cb(GtkWidget *entry, GdkEventButton *event, DictPanelData *dpd)
+{
+ GtkWidget *toplevel;
+
+ if (! entry_is_dirty)
+ {
+ entry_is_dirty = TRUE;
+ if (event->button == 1)
+ gtk_entry_set_text(GTK_ENTRY(entry), "");
+ }
+
+ /* Determine toplevel parent widget */
+ toplevel = gtk_widget_get_toplevel(entry);
+
+ /* Grab entry focus if possible */
+ if (event->button != 3 && toplevel && toplevel->window)
+ xfce_panel_plugin_focus_widget(dpd->plugin, entry);
+
+ return FALSE;
+}
+
+
+static void entry_changed_cb(GtkEditable *editable, DictData *dd)
+{
+ entry_is_dirty = TRUE;
+}
+
+
static void dict_plugin_drag_data_received(GtkWidget *widget, GdkDragContext *drag_context,
gint x, gint y, GtkSelectionData *data, guint info, guint ltime, DictPanelData *dpd)
{
@@ -428,12 +435,10 @@
dpd->dd->panel_entry = sexy_icon_entry_new_full(NULL, "gtk-clear");
gtk_entry_set_width_chars(GTK_ENTRY(dpd->dd->panel_entry), 25);
gtk_entry_set_text(GTK_ENTRY(dpd->dd->panel_entry), _("Search term"));
- g_signal_connect(dpd->dd->panel_entry, "icon_released",
- G_CALLBACK(entry_icon_pressed_cb), dpd);
- g_signal_connect(dpd->dd->panel_entry, "activate",
- G_CALLBACK(dict_plugin_panel_entry_activate_cb), dpd);
- g_signal_connect(dpd->dd->panel_entry, "button-press-event",
- G_CALLBACK(dict_plugin_panel_entry_buttonpress_cb), dpd);
+ g_signal_connect(dpd->dd->panel_entry, "icon_released", G_CALLBACK(entry_icon_pressed_cb), dpd);
+ g_signal_connect(dpd->dd->panel_entry, "activate", G_CALLBACK(entry_activate_cb), dpd);
+ g_signal_connect(dpd->dd->panel_entry, "button-press-event", G_CALLBACK(entry_buttonpress_cb), dpd);
+ g_signal_connect(dpd->dd->panel_entry, "changed", G_CALLBACK(entry_changed_cb), dpd);
if (dpd->dd->show_panel_entry &&
xfce_panel_plugin_get_orientation(dpd->plugin) == GTK_ORIENTATION_HORIZONTAL)
More information about the Goodies-commits
mailing list