Code

Add warning dialog for other than "newest" GTK.
authorJon A. Cruz <jon@joncruz.org>
Mon, 26 Apr 2010 08:23:10 +0000 (01:23 -0700)
committerJon A. Cruz <jon@joncruz.org>
Mon, 26 Apr 2010 08:23:10 +0000 (01:23 -0700)
src/ink-comboboxentry-action.cpp
src/ink-comboboxentry-action.h

index 60332e02ea72d2363dfa040758dfb96739dda6df..de0af347c7699e1f117e151f53da8c63f15964c0 100644 (file)
@@ -7,6 +7,7 @@
  *
  * Author(s):
  *   Tavmjong Bah
+ *   Jon A. Cruz <jon@joncruz.org>
  *
  * Copyright (C) 2010 Authors
  *
@@ -245,6 +246,9 @@ static void ink_comboboxentry_action_init (Ink_ComboBoxEntry_Action *action)
   action->active = -1;
   action->text = NULL;
   action->entry_completion = NULL;
+#if !GTK_CHECK_VERSION(2,16,0)
+  action->indicator = NULL;
+#endif
   action->popup = false;
   action->warning = NULL;
   action->altx_name = NULL;
@@ -314,7 +318,15 @@ GtkWidget* create_tool_item( GtkAction* action )
 
     {
         GtkWidget *align = gtk_alignment_new(0, 0.5, 0, 0);
+#if GTK_CHECK_VERSION(2,16,0)
         gtk_container_add( GTK_CONTAINER(align), comboBoxEntry );
+#else // GTK_CHECK_VERSION(2,16,0)
+        GtkWidget *hbox = gtk_hbox_new( FALSE, 0 );
+        ink_comboboxentry_action->indicator = gtk_image_new_from_stock(GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_SMALL_TOOLBAR);
+        gtk_box_pack_start( GTK_BOX(hbox), comboBoxEntry, TRUE, TRUE, 0 );
+        gtk_box_pack_start( GTK_BOX(hbox), ink_comboboxentry_action->indicator, FALSE, FALSE, 0 );
+        gtk_container_add( GTK_CONTAINER(align), hbox );
+#endif // GTK_CHECK_VERSION(2,16,0)
         gtk_container_add( GTK_CONTAINER(item), align );
     }
 
@@ -359,7 +371,9 @@ GtkWidget* create_tool_item( GtkAction* action )
 
     }
 
+#if GTK_CHECK_VERSION(2,16,0)
     gtk_action_connect_proxy( GTK_ACTION( action ), item );
+#endif
 
     gtk_widget_show_all( item );
 
@@ -430,13 +444,18 @@ gboolean ink_comboboxentry_action_set_active_text( Ink_ComboBoxEntry_Action* ink
       gtk_entry_set_icon_tooltip_text( ink_comboboxentry_action->entry,
                                        GTK_ENTRY_ICON_SECONDARY,
                                        ink_comboboxentry_action->warning );
-
+#else // GTK_CHECK_VERSION(2,16,0)
+      gtk_image_set_from_stock( GTK_IMAGE(ink_comboboxentry_action->indicator), GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_SMALL_TOOLBAR);
+      gtk_widget_set_tooltip_text( ink_comboboxentry_action->indicator, ink_comboboxentry_action->warning );
 #endif // GTK_CHECK_VERSION(2,16,0)
     } else {
 #if GTK_CHECK_VERSION(2,16,0)
       gtk_entry_set_icon_from_icon_name( GTK_ENTRY(ink_comboboxentry_action->entry),
                                          GTK_ENTRY_ICON_SECONDARY,
                                          NULL );
+#else // GTK_CHECK_VERSION(2,16,0)
+      gtk_image_set_from_stock( GTK_IMAGE(ink_comboboxentry_action->indicator), NULL, GTK_ICON_SIZE_SMALL_TOOLBAR);
+      gtk_widget_set_tooltip_text( ink_comboboxentry_action->indicator, NULL );
 #endif // GTK_CHECK_VERSION(2,16,0)
     }
   }
@@ -486,6 +505,7 @@ void ink_comboboxentry_action_popup_disable( Ink_ComboBoxEntry_Action* action )
 
   if( action->entry_completion ) {
     gtk_object_destroy( GTK_OBJECT( action->entry_completion ) );
+    action->entry_completion = 0;
   }
 }
 
@@ -500,6 +520,8 @@ void     ink_comboboxentry_action_set_warning( Ink_ComboBoxEntry_Action* action,
     gtk_entry_set_icon_tooltip_text( GTK_ENTRY(action->entry),
                                      GTK_ENTRY_ICON_SECONDARY,
                                      action->warning );
+#else // GTK_CHECK_VERSION(2,16,0)
+    gtk_image_set_from_stock( GTK_IMAGE(action->indicator), action->warning ? GTK_STOCK_DIALOG_WARNING : 0, GTK_ICON_SIZE_SMALL_TOOLBAR );
 #endif // GTK_CHECK_VERSION(2,16,0)
   }
 }
index b1228f749c5344381c4f6b4b029ad245265eddfd..031803d8ab43720592fa0fbbdf835f264198fd60 100644 (file)
@@ -7,6 +7,7 @@
  *
  * Author(s):
  *   Tavmjong Bah
+ *   Jon A. Cruz <jon@joncruz.org>
  *
  * Copyright (C) 2010 Authors
  *
@@ -46,10 +47,13 @@ struct _Ink_ComboBoxEntry_Action {
   GtkComboBoxEntry   *combobox;
   GtkEntry           *entry;
   GtkEntryCompletion *entry_completion;
+#if !GTK_CHECK_VERSION(2,16,0)
+  GtkWidget          *indicator;
+#endif
 
   gpointer            cell_data_func; // drop-down menu format
 
-  gint                active;     // Index of active menu item (-1 if not in list). 
+  gint                active;     // Index of active menu item (-1 if not in list).
   gchar              *text;       // Text of active menu item or entry box.
   gint                width;      // Width of GtkComboBoxEntry in characters.
   gboolean            popup;      // Do we pop-up an entry-completion dialog?
@@ -62,14 +66,14 @@ GType ink_comboboxentry_action_get_type (void);
 
 /**
  * Creates a GtkAction subclass that wraps a GtkComboBoxEntry object.
- */ 
+ */
 Ink_ComboBoxEntry_Action *ink_comboboxentry_action_new ( const gchar  *name,
-                                                        const gchar  *label,
-                                                        const gchar  *tooltip,
-                                                        const gchar  *stock_id,
-                                                        GtkTreeModel *model,
-                                                        gint          width = -1,
-                                                        gpointer cell_data_func = NULL );
+                                                         const gchar  *label,
+                                                         const gchar  *tooltip,
+                                                         const gchar  *stock_id,
+                                                         GtkTreeModel *model,
+                                                         gint          width = -1,
+                                                         gpointer cell_data_func = NULL );
 
 GtkTreeModel     *ink_comboboxentry_action_get_model( Ink_ComboBoxEntry_Action* action );
 GtkComboBoxEntry *ink_comboboxentry_action_get_comboboxentry( Ink_ComboBoxEntry_Action* action );