[nautilus-actions] Display writability status of the item in the status bar



commit c4e6013747e75b45e87ff60670161c9d79a5140f
Author: Pierre Wieser <pwieser trychlos org>
Date:   Sat Dec 19 23:43:40 2009 +0100

    Display writability status of the item in the status bar

 ChangeLog                                          |   27 +++++++
 TODO                                               |    4 +
 nautilus-actions/nact/Makefile.am                  |    1 +
 nautilus-actions/nact/base-window.c                |    3 +
 nautilus-actions/nact/locked.png                   |  Bin 0 -> 1268 bytes
 nautilus-actions/nact/nact-main-statusbar.c        |   79 ++++++++++++++++++--
 nautilus-actions/nact/nact-main-statusbar.h        |    1 +
 nautilus-actions/nact/nact-main-window.c           |    7 ++
 nautilus-actions/nact/nact-window.c                |    2 +
 .../nact/nautilus-actions-config-tool.ui           |   28 +++++++-
 nautilus-actions/runtime/na-iabout.c               |    1 +
 11 files changed, 145 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c87cb0d..3327e7c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,32 @@
 2009-12-19 Pierre Wieser <pwieser trychlos org>
 
+	Display the writability status in the status bar.
+
+	* nautilus-actions/nact/locked.png: New file.
+
+	* nautilus-actions/nact/Makefile.am: Updated accordingly.
+
+	* nautilus-actions/nact/base-window.c (base_window_get_widget):
+	Add a warning when widget is not found.
+
+	* nautilus-actions/nact/nact-main-statusbar.c:
+	* nautilus-actions/nact/nact-main-statusbar.h
+	(nact_main_statusbar_set_locked): New function.
+
+	* nautilus-actions/runtime/na-iabout.c (na_iabout_display):
+	Credit the author of the locked image.
+
+	* nautilus-actions/nact/nautilus-actions-config-tool.ui:
+	Add an image in the status bar.
+
+	* nautilus-actions/nact/nact-main-window.c (set_current_object_item):
+	Update the locked image depending of the writability status of the
+	current item.
+
+	* nautilus-actions/nact/nact-window.c
+	(nact_window_is_writable_provider): Return default writability status
+	when the (new) item doesn't have yet a provider.
+
 	* nautilus-actions/plugin/nautilus-module.c
 	(nautilus_module_initialize):
 	* nautilus-actions/tracker/na-tracker-plugin.c
diff --git a/TODO b/TODO
index 39b950e..f8a3af7 100644
--- a/TODO
+++ b/TODO
@@ -108,3 +108,7 @@
   > remove in n-a-c-t
   > remove in n-a-n
   > remove in action class
+
+- when saving a new item, do not save it in a non-writable provider!
+
+- the locked image is moved to the right (under the grip) at the first item
diff --git a/nautilus-actions/nact/Makefile.am b/nautilus-actions/nact/Makefile.am
index 5f05554..667ab12 100644
--- a/nautilus-actions/nact/Makefile.am
+++ b/nautilus-actions/nact/Makefile.am
@@ -142,6 +142,7 @@ pkgdata_DATA = \
 	nautilus-actions-maintainer.actions							\
 	nact-assistant-export.ui									\
 	nautilus-actions-config-tool.ui								\
+	locked.png													\
 	$(NULL)
 
 @INTLTOOL_DESKTOP_RULE@
diff --git a/nautilus-actions/nact/base-window.c b/nautilus-actions/nact/base-window.c
index 4e51f9d..9117067 100644
--- a/nautilus-actions/nact/base-window.c
+++ b/nautilus-actions/nact/base-window.c
@@ -810,6 +810,9 @@ base_window_get_widget( BaseWindow *window, const gchar *name )
 	if( !window->private->dispose_has_run ){
 		toplevel = window->private->toplevel_window;
 		widget = search_for_widget( toplevel, name );
+		if( !widget ){
+			g_warning( "%s: widget not found", name );
+		}
 	}
 
 	return( widget );
diff --git a/nautilus-actions/nact/locked.png b/nautilus-actions/nact/locked.png
new file mode 100644
index 0000000..88b7cdb
Binary files /dev/null and b/nautilus-actions/nact/locked.png differ
diff --git a/nautilus-actions/nact/nact-main-statusbar.c b/nautilus-actions/nact/nact-main-statusbar.c
index eecf12a..e81d947 100644
--- a/nautilus-actions/nact/nact-main-statusbar.c
+++ b/nautilus-actions/nact/nact-main-statusbar.c
@@ -41,15 +41,28 @@ typedef struct {
 }
 	StatusbarTimeoutDisplayStruct;
 
+#define LOCKED_IMAGE					PKGDATADIR "/locked.png"
+
 static GtkStatusbar *get_statusbar( const NactMainWindow *window );
 static gboolean      display_timeout( StatusbarTimeoutDisplayStruct *stds );
 static void          display_timeout_free( StatusbarTimeoutDisplayStruct *stds );
 
+/**
+ * nact_main_statusbar_display_status:
+ * @window: the #NactMainWindow instance.
+ * @context: the context to be displayed.
+ * @status: the message.
+ *
+ * Push a message.
+ */
 void
 nact_main_statusbar_display_status( NactMainWindow *window, const gchar *context, const gchar *status )
 {
+	static const gchar *thisfn = "nact_main_statusbar_display_status";
 	GtkStatusbar *bar;
 
+	g_debug( "%s: window=%p, context=%s, status=%s", thisfn, ( void * ) window, context, status );
+
 	if( !status || !g_utf8_strlen( status, -1 )){
 		return;
 	}
@@ -62,18 +75,26 @@ nact_main_statusbar_display_status( NactMainWindow *window, const gchar *context
 	}
 }
 
-/*
- * push a message
- * automatically pop it after a timeout
- * the timeout is not suspended when another message is pushed onto the
- * previous one
+/**
+ * nact_main_statusbar_display_with_timeout:
+ * @window: the #NactMainWindow instance.
+ * @context: the context to be displayed.
+ * @status: the message.
+ *
+ * Push a message.
+ * Automatically pop it after a timeout.
+ * The timeout is not suspended when another message is pushed onto the
+ * previous one.
  */
 void
 nact_main_statusbar_display_with_timeout( NactMainWindow *window, const gchar *context, const gchar *status )
 {
+	static const gchar *thisfn = "nact_main_statusbar_display_with_timeout";
 	GtkStatusbar *bar;
 	StatusbarTimeoutDisplayStruct *stds;
 
+	g_debug( "%s: window=%p, context=%s, status=%s", thisfn, ( void * ) window, context, status );
+
 	if( !status || !g_utf8_strlen( status, -1 )){
 		return;
 	}
@@ -96,11 +117,21 @@ nact_main_statusbar_display_with_timeout( NactMainWindow *window, const gchar *c
 	}
 }
 
+/**
+ * nact_main_statusbar_hide_status:
+ * @window: the #NactMainWindow instance.
+ * @context: the context to be hidden.
+ *
+ * Hide the specified context.
+ */
 void
 nact_main_statusbar_hide_status( NactMainWindow *window, const gchar *context )
 {
+	static const gchar *thisfn = "nact_main_statusbar_hide_status";
 	GtkStatusbar *bar;
 
+	g_debug( "%s: window=%p, context=%s", thisfn, ( void * ) window, context );
+
 	bar = get_statusbar( window );
 
 	if( bar ){
@@ -109,6 +140,42 @@ nact_main_statusbar_hide_status( NactMainWindow *window, const gchar *context )
 	}
 }
 
+/**
+ * nact_main_statusbar_set_locked:
+ * @window: the #NactMainWindow instance.
+ * @locked: whether the current item is locked.
+ *
+ * Displays the writability status of the current item as an image.
+ */
+void
+nact_main_statusbar_set_locked( NactMainWindow *window, gboolean locked )
+{
+	static const gchar *thisfn = "nact_main_statusbar_set_locked";
+	GtkStatusbar *bar;
+	GtkFrame *frame;
+	GtkImage *image;
+
+	g_debug( "%s: window=%p, locked=%s", thisfn, ( void * ) window, locked ? "True":"False" );
+
+	bar = get_statusbar( window );
+	frame = GTK_FRAME( base_window_get_widget( BASE_WINDOW( window ), "ActionLockedFrame" ));
+	image = GTK_IMAGE( base_window_get_widget( BASE_WINDOW( window ), "ActionLockedImage" ));
+
+	if( bar && frame && image ){
+
+		if( locked ){
+			gtk_image_set_from_file( image, LOCKED_IMAGE );
+			gtk_widget_show( GTK_WIDGET( image ));
+			gtk_frame_set_shadow_type( frame, GTK_SHADOW_NONE );
+
+		} else {
+			gtk_image_set_from_icon_name( image, "gnome-stock-blank", GTK_ICON_SIZE_MENU );
+			gtk_widget_hide( GTK_WIDGET( image ));
+			gtk_frame_set_shadow_type( frame, GTK_SHADOW_IN );
+		}
+	}
+}
+
 /*
  * Returns the status bar widget
  */
@@ -117,7 +184,7 @@ get_statusbar( const NactMainWindow *window )
 {
 	GtkWidget *statusbar;
 
-	statusbar = base_window_get_widget( BASE_WINDOW( window ), "StatusBar" );
+	statusbar = base_window_get_widget( BASE_WINDOW( window ), "MainStatusbar" );
 
 	return( GTK_STATUSBAR( statusbar ));
 }
diff --git a/nautilus-actions/nact/nact-main-statusbar.h b/nautilus-actions/nact/nact-main-statusbar.h
index 83c4854..9937f5d 100644
--- a/nautilus-actions/nact/nact-main-statusbar.h
+++ b/nautilus-actions/nact/nact-main-statusbar.h
@@ -44,6 +44,7 @@ G_BEGIN_DECLS
 void  nact_main_statusbar_display_status( NactMainWindow *window, const gchar *context, const gchar *status );
 void  nact_main_statusbar_display_with_timeout( NactMainWindow *window, const gchar *context, const gchar *status );
 void  nact_main_statusbar_hide_status( NactMainWindow *window, const gchar *context );
+void  nact_main_statusbar_set_locked( NactMainWindow *window, gboolean locked );
 
 G_END_DECLS
 
diff --git a/nautilus-actions/nact/nact-main-window.c b/nautilus-actions/nact/nact-main-window.c
index 9a1f166..f8f4a0f 100644
--- a/nautilus-actions/nact/nact-main-window.c
+++ b/nautilus-actions/nact/nact-main-window.c
@@ -54,6 +54,7 @@
 #include "nact-iadvanced-tab.h"
 #include "nact-main-tab.h"
 #include "nact-main-menubar.h"
+#include "nact-main-statusbar.h"
 #include "nact-marshal.h"
 #include "nact-main-window.h"
 #include "nact-confirm-logout.h"
@@ -1006,6 +1007,8 @@ on_base_initial_load_toplevel( NactMainWindow *window, gpointer user_data )
 		nact_ibackground_tab_initial_load_toplevel( NACT_IBACKGROUND_TAB( window ));
 		nact_iconditions_tab_initial_load_toplevel( NACT_ICONDITIONS_TAB( window ));
 		nact_iadvanced_tab_initial_load_toplevel( NACT_IADVANCED_TAB( window ));
+
+		nact_main_statusbar_set_locked( window, FALSE );
 	}
 }
 
@@ -1109,6 +1112,8 @@ on_iactions_list_selection_changed( NactIActionsList *instance, GSList *selected
 		return;
 	}
 
+	nact_main_statusbar_set_locked( window, FALSE );
+
 	if( count == 1 ){
 		g_return_if_fail( NA_IS_OBJECT_ID( selected_items->data ));
 		object = NA_OBJECT( selected_items->data );
@@ -1175,6 +1180,8 @@ set_current_object_item( NactMainWindow *window, GSList *selected_items )
 		window->private->readonly_item = na_object_is_readonly( window->private->edited_item );
 		window->private->writable_provider = nact_window_is_writable_provider( NACT_WINDOW( window ), window->private->edited_item );
 
+		nact_main_statusbar_set_locked( window, window->private->readonly_item || !window->private->writable_provider );
+
 		if( NA_IS_OBJECT_ACTION( window->private->edited_item )){
 
 			count_profiles = na_object_get_items_count( NA_OBJECT_ACTION( window->private->edited_item ));
diff --git a/nautilus-actions/nact/nact-window.c b/nautilus-actions/nact/nact-window.c
index ddeab2e..0ba235f 100644
--- a/nautilus-actions/nact/nact-window.c
+++ b/nautilus-actions/nact/nact-window.c
@@ -225,6 +225,8 @@ nact_window_is_writable_provider( NactWindow *window, const NAObjectItem *item )
 		provider = na_object_get_provider( item );
 		if( provider ){
 			writable = na_io_provider_is_willing_to_write( pivot, provider );
+		} else {
+			writable = nact_window_has_writable_providers( window );
 		}
 	}
 
diff --git a/nautilus-actions/nact/nautilus-actions-config-tool.ui b/nautilus-actions/nact/nautilus-actions-config-tool.ui
index 28b33ff..521e7dc 100644
--- a/nautilus-actions/nact/nautilus-actions-config-tool.ui
+++ b/nautilus-actions/nact/nautilus-actions-config-tool.ui
@@ -1289,9 +1289,33 @@ Defining several profiles lets you have several commands, each applying with a d
           </packing>
         </child>
         <child>
-          <object class="GtkStatusbar" id="StatusBar">
+          <object class="GtkStatusbar" id="MainStatusbar">
             <property name="visible">True</property>
             <property name="spacing">2</property>
+            <child>
+              <object class="GtkAspectFrame" id="ActionLockedFrame">
+                <property name="width_request">24</property>
+                <property name="height_request">24</property>
+                <property name="visible">True</property>
+                <property name="label_xalign">0</property>
+                <property name="shadow_type">none</property>
+                <property name="obey_child">False</property>
+                <child>
+                  <object class="GtkImage" id="ActionLockedImage">
+                    <property name="visible">True</property>
+                    <property name="stock">gnome-stock-blank</property>
+                    <property name="icon-size">1</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="padding">4</property>
+                <property name="pack_type">end</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
           </object>
           <packing>
             <property name="expand">False</property>
@@ -1322,9 +1346,9 @@ Defining several profiles lets you have several commands, each applying with a d
           <object class="GtkFileChooserWidget" id="ImportFileChooser">
             <property name="visible">True</property>
             <property name="local_only">False</property>
-            <property name="use_preview_label">False</property>
             <property name="select_multiple">True</property>
             <property name="preview_widget_active">False</property>
+            <property name="use_preview_label">False</property>
           </object>
           <packing>
             <property name="position">0</property>
diff --git a/nautilus-actions/runtime/na-iabout.c b/nautilus-actions/runtime/na-iabout.c
index e767815..d46994e 100644
--- a/nautilus-actions/runtime/na-iabout.c
+++ b/nautilus-actions/runtime/na-iabout.c
@@ -159,6 +159,7 @@ na_iabout_display( NAIAbout *instance )
 
 	static const gchar *artists[] = {
 		"Ulisse Perusin <uli peru gmail com>",
+		"DragonArtz - http://www.dragonartz.net/";,
 		NULL
 	};
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]