[Xfce4-commits] <thunar:nick/1.8> Some small improvements.

Nick Schermer noreply at xfce.org
Sun Aug 4 21:52:17 CEST 2013


Updating branch refs/heads/nick/1.8
         to 6beeef33d489e853ce034b1c57f64badc0aadaf9 (commit)
       from 3e9d617d3f5b5182c2aab4c0a40d273da5838541 (commit)

commit 6beeef33d489e853ce034b1c57f64badc0aadaf9
Author: Nick Schermer <nick at xfce.org>
Date:   Wed Jul 31 23:37:59 2013 +0200

    Some small improvements.

 thunar/thunar-desktop-background-icon-view.c |    2 +-
 thunar/thunar-desktop-preferences-dialog.c   |   28 +++++++----
 thunar/thunar-desktop-window.c               |   67 +++++++++++++++++++++++++-
 3 files changed, 85 insertions(+), 12 deletions(-)

diff --git a/thunar/thunar-desktop-background-icon-view.c b/thunar/thunar-desktop-background-icon-view.c
index 32ad82b..057b0f9 100644
--- a/thunar/thunar-desktop-background-icon-view.c
+++ b/thunar/thunar-desktop-background-icon-view.c
@@ -82,7 +82,7 @@ thunar_desktop_background_icon_view_init (ThunarDesktopBackgroundIconView *icon_
   /* only a single selection is possible */
   exo_view = gtk_bin_get_child (GTK_BIN (icon_view));
   exo_icon_view_set_selection_mode (EXO_ICON_VIEW (exo_view), GTK_SELECTION_BROWSE);
-  exo_icon_view_set_enable_search (EXO_ICON_VIEW (exo_view), TRUE);
+  exo_icon_view_set_enable_search (EXO_ICON_VIEW (exo_view), FALSE);
 
   /* setup the icon renderer */
   g_object_set (G_OBJECT (THUNAR_STANDARD_VIEW (icon_view)->icon_renderer),
diff --git a/thunar/thunar-desktop-preferences-dialog.c b/thunar/thunar-desktop-preferences-dialog.c
index a63feaa..666aea6 100644
--- a/thunar/thunar-desktop-preferences-dialog.c
+++ b/thunar/thunar-desktop-preferences-dialog.c
@@ -56,7 +56,7 @@ static gboolean thunar_desktop_preferences_dialog_configure_event           (Gtk
 static void     thunar_desktop_preferences_dialog_response                  (GtkDialog                      *dialog,
                                                                              gint                            response);
 static void     thunar_desktop_preferences_dialog_background_changed        (ThunarDesktopPreferencesDialog *dialog);
-static void     thunar_desktop_preferences_dialog_background_prop           (ThunarDesktopPreferencesDialog *dialog);
+static gboolean thunar_desktop_preferences_dialog_background_prop           (ThunarDesktopPreferencesDialog *dialog);
 static gboolean thunar_desktop_preferences_dialog_update                    (gpointer                        data);
 static void     thunar_desktop_preferences_dialog_folder_changed            (ThunarDesktopPreferencesDialog *dialog);
 static void     thunar_desktop_preferences_dialog_style_changed             (ThunarDesktopPreferencesDialog *dialog);
@@ -168,7 +168,7 @@ thunar_desktop_preferences_dialog_init (ThunarDesktopPreferencesDialog *dialog)
 
   /* configure the dialog properties */
   gtk_window_set_icon_name (GTK_WINDOW (dialog), "preferences-desktop-wallpaper");
-  gtk_window_set_default_size (GTK_WINDOW (dialog), 900, 700);
+  gtk_window_set_default_size (GTK_WINDOW (dialog), 635, 575);
 
   /* add "Help" and "Close" buttons */
   gtk_dialog_add_buttons (GTK_DIALOG (dialog),
@@ -284,7 +284,7 @@ thunar_desktop_preferences_dialog_init (ThunarDesktopPreferencesDialog *dialog)
   gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
   gtk_widget_show (hbox);
 
-  button = gtk_check_button_new_with_mnemonic (_("Ch_ange background(s)"));
+  button = gtk_check_button_new_with_mnemonic (_("Ch_ange backgrounds"));
   gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
   xfconf_g_property_bind (dialog->settings, "/background/cycle/enabled",
                           G_TYPE_BOOLEAN, button, "active");
@@ -497,7 +497,8 @@ thunar_desktop_preferences_dialog_update (gpointer data)
   dialog->dialog_update_timeout = 0;
 
   /* update the base property */
-  thunar_desktop_preferences_dialog_background_prop (dialog);
+  if (!thunar_desktop_preferences_dialog_background_prop (dialog))
+    return FALSE;
 
   /* background image */
   g_snprintf (prop, sizeof (prop), "%s/uri", dialog->background_prop);
@@ -583,7 +584,7 @@ thunar_desktop_preferences_dialog_background_changed (ThunarDesktopPreferencesDi
 
 
 
-static void
+static gboolean
 thunar_desktop_preferences_dialog_background_prop (ThunarDesktopPreferencesDialog *dialog)
 {
   GdkScreen *screen;
@@ -591,8 +592,8 @@ thunar_desktop_preferences_dialog_background_prop (ThunarDesktopPreferencesDialo
   gchar     *monitor_name;
   gchar     *nice_name;
   gchar     *title;
-
-  g_free (dialog->background_prop);
+  gchar     *prop;
+  gboolean   changed;
 
   screen = gtk_window_get_screen (GTK_WINDOW (dialog));
   monitor_num = gdk_screen_get_monitor_at_window (screen, gtk_widget_get_window (GTK_WIDGET (dialog)));
@@ -626,11 +627,18 @@ thunar_desktop_preferences_dialog_background_prop (ThunarDesktopPreferencesDialo
     monitor_name = g_strdup_printf ("monitor-%d", monitor_num);
 
   /* xfconf base property for settings in this dialog */
-  dialog->background_prop = g_strdup_printf ("/background/screen-%d/%s",
-                                             gdk_screen_get_number (screen),
-                                             monitor_name);
+  prop = g_strdup_printf ("/background/screen-%d/%s",
+                          gdk_screen_get_number (screen),
+                          monitor_name);
+
+  changed = g_strcmp0 (prop, dialog->background_prop) != 0;
+
+  g_free (dialog->background_prop);
+  dialog->background_prop = prop;
 
   g_free (monitor_name);
+
+  return changed;
 }
 
 
diff --git a/thunar/thunar-desktop-window.c b/thunar/thunar-desktop-window.c
index dfa48da..e36cdbb 100644
--- a/thunar/thunar-desktop-window.c
+++ b/thunar/thunar-desktop-window.c
@@ -21,6 +21,8 @@
 #include <config.h>
 #endif
 
+#include <libxfce4util/libxfce4util.h>
+
 #include <thunar/thunar-private.h>
 #include <thunar/thunar-desktop-window.h>
 #include <thunar/thunar-desktop-background.h>
@@ -40,7 +42,10 @@ static gboolean thunar_desktop_window_expose_event              (GtkWidget
                                                                  GdkEventExpose           *event);
 static gboolean thunar_desktop_window_button_press_event        (GtkWidget                *widget,
                                                                  GdkEventButton           *event);
-
+static gboolean thunar_desktop_window_scroll_event              (GtkWidget                *widget,
+                                                                 GdkEventScroll           *event);
+static gboolean thunar_desktop_window_delete_event              (GtkWidget                *widget,
+                                                                 GdkEventAny              *event);
 
 
 struct _ThunarDesktopWindowClass
@@ -72,6 +77,8 @@ thunar_desktop_window_class_init (ThunarDesktopWindowClass *klass)
   gtkwidget_class->unrealize = thunar_desktop_window_unrealize;
   gtkwidget_class->expose_event = thunar_desktop_window_expose_event;
   gtkwidget_class->button_press_event = thunar_desktop_window_button_press_event;
+  gtkwidget_class->scroll_event = thunar_desktop_window_scroll_event;
+  gtkwidget_class->delete_event = thunar_desktop_window_delete_event;
 }
 
 
@@ -85,6 +92,8 @@ thunar_desktop_window_init (ThunarDesktopWindow *window)
   gtk_window_move (GTK_WINDOW (window), 0, 0);
   gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_DESKTOP);
   gtk_widget_set_double_buffered (GTK_WIDGET (window), FALSE);
+  gtk_window_set_accept_focus (GTK_WINDOW (window), FALSE);
+  gtk_window_set_title (GTK_WINDOW (window), _("Desktop"));
 }
 
 
@@ -199,6 +208,8 @@ thunar_desktop_window_expose_event (GtkWidget      *widget,
                          event->area.x, event->area.y,
                          event->area.width, event->area.height);
 
+  /* TODO propagate children */
+
   return FALSE;
 }
 
@@ -226,6 +237,60 @@ thunar_desktop_window_button_press_event (GtkWidget      *widget,
 
 
 
+static gboolean
+thunar_desktop_window_scroll_event (GtkWidget      *widget,
+                                    GdkEventScroll *event)
+{
+#ifdef GDK_WINDOWING_X11
+  XButtonEvent  xev;
+  gint          button;
+  GdkWindow    *root_window;
+
+  root_window = gdk_screen_get_root_window (gtk_widget_get_screen (widget));
+
+  /* create an event for the root window */
+  xev.window = GDK_WINDOW_XWINDOW (root_window);
+  xev.button = event->direction + 4;
+  xev.x = event->x; /* needed for icewm */
+  xev.y = event->y;
+  xev.x_root = event->x_root;
+  xev.y_root = event->y_root;
+  xev.state = event->state;
+  xev.root =  xev.window;
+  xev.subwindow = None;
+  xev.time = event->time;
+  xev.same_screen = True;
+
+  /* send a button press and release */
+  for (button = ButtonPress; button < ButtonRelease; button++)
+    {
+      xev.type = button;
+
+      /* forward event to root window */
+      XSendEvent (GDK_WINDOW_XDISPLAY (root_window),
+                  xev.window, False,
+                  ButtonPressMask | ButtonReleaseMask,
+                  (XEvent *) &xev);
+    }
+#endif
+
+  return TRUE;
+}
+
+
+
+static gboolean
+thunar_desktop_window_delete_event (GtkWidget   *widget,
+                                    GdkEventAny *event)
+{
+  /* TODO: hoopup session logout handler here */
+
+  /* never close the window */
+  return TRUE;
+}
+
+
+
 /**
  * thunar_desktop_window_new:
  *


More information about the Xfce4-commits mailing list