[Goodies-commits] r6610 - ristretto/branches/ristretto-gio/src

Stephan Arts stephan at xfce.org
Sat Jan 31 11:00:12 CET 2009


Author: stephan
Date: 2009-01-31 10:00:12 +0000 (Sat, 31 Jan 2009)
New Revision: 6610

Modified:
   ristretto/branches/ristretto-gio/src/main_window.c
   ristretto/branches/ristretto-gio/src/main_window_ui.xml
   ristretto/branches/ristretto-gio/src/preferences_dialog.c
   ristretto/branches/ristretto-gio/src/preferences_dialog.h
Log:
Make pause and play share accelerators
Add xfce titled header to preferences dialog



Modified: ristretto/branches/ristretto-gio/src/main_window.c
===================================================================
--- ristretto/branches/ristretto-gio/src/main_window.c	2009-01-30 23:29:05 UTC (rev 6609)
+++ ristretto/branches/ristretto-gio/src/main_window.c	2009-01-31 10:00:12 UTC (rev 6610)
@@ -37,6 +37,8 @@
 #include "main_window.h"
 #include "main_window_ui.h"
 
+#include "preferences_dialog.h"
+
 #define XFDESKTOP_SELECTION_FMT "XFDESKTOP_SELECTION_%d"
 
 #ifndef RISTRETTO_APP_TITLE
@@ -142,6 +144,8 @@
 
 static void
 cb_rstto_main_window_play (GtkWidget *widget, RsttoMainWindow *window);
+static void
+cb_rstto_main_window_pause(GtkWidget *widget, RsttoMainWindow *window);
 
 static void
 cb_rstto_main_window_toggle_show_toolbar (GtkWidget *widget, RsttoMainWindow *window);
@@ -199,6 +203,7 @@
   { "first",    GTK_STOCK_GOTO_FIRST, N_ ("_First"), "Home", NULL, G_CALLBACK (cb_rstto_main_window_first_image), },
   { "last",     GTK_STOCK_GOTO_LAST, N_ ("_Last"), "End", NULL, G_CALLBACK (cb_rstto_main_window_last_image), },
   { "play",     GTK_STOCK_MEDIA_PLAY, N_ ("_Play"), "F5", NULL, G_CALLBACK (cb_rstto_main_window_play), },
+  { "pause",     GTK_STOCK_MEDIA_PAUSE, N_ ("_Pause"), "F5", NULL, G_CALLBACK (cb_rstto_main_window_pause), },
 /* Help Menu */
   { "help-menu", NULL, N_ ("_Help"), NULL, },
   { "contents", GTK_STOCK_HELP,
@@ -304,6 +309,8 @@
 
     rstto_main_window_set_sensitive (window, FALSE);
     gtk_widget_set_no_show_all (window->priv->toolbar, TRUE);
+    gtk_widget_set_no_show_all (gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-menu/go-menu/play"), TRUE);
+    gtk_widget_set_no_show_all (gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-menu/go-menu/pause"), TRUE);
 
     g_value_init (&window_width, G_TYPE_UINT);
     g_value_init (&window_height, G_TYPE_UINT);
@@ -365,6 +372,14 @@
     RsttoMainWindow *window = RSTTO_MAIN_WINDOW(object);
     G_OBJECT_CLASS (parent_class)->dispose(object); 
 
+    if (window->priv->ui_manager)
+    {
+        /** TODO:
+         * reset accelerator on 'play' and free ui_manager
+         */
+        window->priv->ui_manager = NULL;
+    } 
+
     if (window->priv->settings_manager)
     {
         g_object_unref (window->priv->settings_manager);
@@ -472,6 +487,7 @@
     gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-menu/go-menu/first"), sensitive);
     gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-menu/go-menu/last"), sensitive); 
     gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-menu/go-menu/play"), sensitive);
+    gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-menu/go-menu/pause"), sensitive);
 
     /* View Menu */
     gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager, 
@@ -855,10 +871,44 @@
 static void
 cb_rstto_main_window_play (GtkWidget *widget, RsttoMainWindow *window)
 {
+    GtkAccelKey key;
     g_debug ("%s", __FUNCTION__);
+    gtk_widget_hide (gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-menu/go-menu/play"));
+    gtk_widget_show (gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-menu/go-menu/pause"));
+    if (gtk_accel_map_lookup_entry ("<Actions>/RsttoWindow/play", &key))
+    {
+        gtk_accel_map_change_entry ("<Actions>/RsttoWindow/pause",
+                                    key.accel_key,
+                                    key.accel_mods,
+                                    TRUE);   
+    }
 }
 
 /**
+ * cb_rstto_main_window_pause:
+ * @widget:
+ * @window:
+ *
+ *
+ */
+static void
+cb_rstto_main_window_pause (GtkWidget *widget, RsttoMainWindow *window)
+{
+    GtkAccelKey key;
+
+    g_debug ("%s", __FUNCTION__);
+    gtk_widget_show (gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-menu/go-menu/play"));
+    gtk_widget_hide (gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-menu/go-menu/pause"));
+    if (gtk_accel_map_lookup_entry ("<Actions>/RsttoWindow/pause", &key))
+    {
+        gtk_accel_map_change_entry ("<Actions>/RsttoWindow/play",
+                                    key.accel_key,
+                                    key.accel_mods,
+                                    TRUE);   
+    }
+}
+
+/**
  * cb_rstto_main_window_fullscreen:
  * @widget:
  * @window:
@@ -889,7 +939,9 @@
 static void
 cb_rstto_main_window_preferences (GtkWidget *widget, RsttoMainWindow *window)
 {
-    g_debug ("%s", __FUNCTION__);
+    GtkWidget *dialog = rstto_preferences_dialog_new (GTK_WINDOW (window));
+    gtk_dialog_run (GTK_DIALOG (dialog));
+    gtk_widget_destroy (dialog);
 }
 
 /**

Modified: ristretto/branches/ristretto-gio/src/main_window_ui.xml
===================================================================
--- ristretto/branches/ristretto-gio/src/main_window_ui.xml	2009-01-30 23:29:05 UTC (rev 6609)
+++ ristretto/branches/ristretto-gio/src/main_window_ui.xml	2009-01-31 10:00:12 UTC (rev 6610)
@@ -49,6 +49,7 @@
             <menuitem action="last"/>
             <separator/>
             <menuitem action="play"/>
+            <menuitem action="pause"/>
         </menu>
         <menu action="help-menu">
             <menuitem action="contents"/>

Modified: ristretto/branches/ristretto-gio/src/preferences_dialog.c
===================================================================
--- ristretto/branches/ristretto-gio/src/preferences_dialog.c	2009-01-30 23:29:05 UTC (rev 6609)
+++ ristretto/branches/ristretto-gio/src/preferences_dialog.c	2009-01-31 10:00:12 UTC (rev 6610)
@@ -18,6 +18,7 @@
 
 #include <config.h>
 #include <gtk/gtk.h>
+#include <libxfcegui4/libxfcegui4.h>
 
 #include "preferences_dialog.h"
 
@@ -49,7 +50,7 @@
             NULL
         };
 
-        rstto_preferences_dialog_type = g_type_register_static (GTK_TYPE_DIALOG, "RsttoPreferencesDialog", &rstto_preferences_dialog_info, 0);
+        rstto_preferences_dialog_type = g_type_register_static (XFCE_TYPE_TITLED_DIALOG, "RsttoPreferencesDialog", &rstto_preferences_dialog_info, 0);
     }
     return rstto_preferences_dialog_type;
 }
@@ -57,6 +58,7 @@
 static void
 rstto_preferences_dialog_init(RsttoPreferencesDialog *dialog)
 {
+    gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CLOSE, GTK_RESPONSE_OK);
 }
 
 static void
@@ -69,7 +71,10 @@
 GtkWidget *
 rstto_preferences_dialog_new (GtkWindow *parent)
 {
-    GtkWidget *dialog = g_object_new (RSTTO_TYPE_PREFERENCES_DIALOG, NULL);
+    GtkWidget *dialog = g_object_new (RSTTO_TYPE_PREFERENCES_DIALOG,
+                                      "title", _("Preferences"),
+                                      "icon-name", "go-left",
+                                      NULL);
     gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
 
     return dialog;

Modified: ristretto/branches/ristretto-gio/src/preferences_dialog.h
===================================================================
--- ristretto/branches/ristretto-gio/src/preferences_dialog.h	2009-01-30 23:29:05 UTC (rev 6609)
+++ ristretto/branches/ristretto-gio/src/preferences_dialog.h	2009-01-31 10:00:12 UTC (rev 6610)
@@ -45,14 +45,14 @@
 
 struct _RsttoPreferencesDialog
 {
-    GtkDialog         parent;
+    XfceTitledDialog parent;
 };
 
 typedef struct _RsttoPreferencesDialogClass RsttoPreferencesDialogClass;
 
 struct _RsttoPreferencesDialogClass
 {
-    GtkDialogClass  parent_class;
+    XfceTitledDialogClass  parent_class;
 };
 
 GType      rstto_preferences_dialog_get_type();




More information about the Goodies-commits mailing list