[f-spot] Migration almost done.



commit 601dfc11e0afd447b420dbfc51f526db54b42cd4
Author: Peter Goetz <peter gtz gmail com>
Date:   Wed Jun 9 01:12:09 2010 +0200

    Migration almost done.
    
    Core functionality works.
    Indentation of combobox entries is not correct yet.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=620837

 src/Makefile.am             |    1 +
 src/TagCommands.cs          |   51 ++++++++------
 src/f-spot.glade            |  156 ---------------------------------------
 src/ui/create_tag_dialog.ui |  169 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 199 insertions(+), 178 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index ffe6e45..52d15b0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -227,6 +227,7 @@ RESOURCES = \
 	UI.Dialog/ui/EditTagIconDialog.ui \
 	UI.Dialog/ui/PreferenceDialog.ui \
 	UI.Dialog/ui/RatingFilterDialog.ui \
+	ui/create_tag_dialog.ui \
 	FSpot.addin.xml
 
 include $(top_srcdir)/build/build.mk
diff --git a/src/TagCommands.cs b/src/TagCommands.cs
index deaf2ad..ff8a949 100644
--- a/src/TagCommands.cs
+++ b/src/TagCommands.cs
@@ -12,6 +12,7 @@
  */
 
 using Gtk;
+using Gdk;
 using System;
 using System.Text;
 using System.Collections;
@@ -30,18 +31,18 @@ public class TagCommands {
 		Category
 	}
 
-	public class Create : GladeDialog {
+	public class Create : BuilderDialog {
 		TagStore tag_store;
 
 
-		[Glade.Widget] private Button create_button;
-		[Glade.Widget] private Entry tag_name_entry;
-		[Glade.Widget] private Label prompt_label;
-		[Glade.Widget] private Label already_in_use_label;
-		[Glade.Widget] private Label photo_label;
-		[Glade.Widget] private ScrolledWindow photo_scrolled_window;
-		[Glade.Widget] private OptionMenu category_option_menu;
-		[Glade.Widget] private CheckButton auto_icon_checkbutton;
+		[GtkBeans.Builder.Object] private Button create_button;
+		[GtkBeans.Builder.Object] private Entry tag_name_entry;
+		[GtkBeans.Builder.Object] private Label prompt_label;
+		[GtkBeans.Builder.Object] private Label already_in_use_label;
+		[GtkBeans.Builder.Object] private Label photo_label;
+		[GtkBeans.Builder.Object] private ScrolledWindow photo_scrolled_window;
+		[GtkBeans.Builder.Object] private ComboBox category_option_menu;
+		[GtkBeans.Builder.Object] private CheckButton auto_icon_checkbutton;
 
 		Gtk.Widget parent_window;
 
@@ -63,15 +64,23 @@ public class TagCommands {
 			categories.Add (tag_store.RootCategory);
 			PopulateCategories (categories, tag_store.RootCategory);
 
-			Menu menu = new Menu ();
+			ListStore category_store = new ListStore(typeof(Pixbuf), typeof(string));
 
 			foreach (Category category in categories)
-				menu.Append (TagMenu.TagMenuItem.IndentedItem (category));
+				category_store.AppendValues(category.SizedIcon, category.Name);
 
 			category_option_menu.Sensitive = true;
 
-			menu.ShowAll ();
-			category_option_menu.Menu = menu;
+			category_option_menu.Model = category_store;
+			var icon_renderer = new CellRendererPixbuf();
+			category_option_menu.PackStart(icon_renderer, true);
+
+			var text_renderer = new CellRendererText();
+			category_option_menu.PackStart(text_renderer, true);
+
+			category_option_menu.AddAttribute(icon_renderer, "pixbuf", 0);
+			category_option_menu.AddAttribute(text_renderer, "text", 1);
+			category_option_menu.ShowAll ();
 		}
 
 		private bool TagNameExistsInCategory (string name, Category category)
@@ -111,7 +120,7 @@ public class TagCommands {
 				if (categories.Count == 0)
 					return tag_store.RootCategory;
 				else
-					return categories [category_option_menu.History] as Category;
+					return categories [category_option_menu.Active] as Category;
 			}
 			set {
 				if ((value != null) && (categories.Count > 0)) {
@@ -120,7 +129,7 @@ public class TagCommands {
 						Category category = (Category)categories[i];
 						// should there be an equals type method?
 						if (value.Id == category.Id) {
-							category_option_menu.SetHistory((uint)i);
+							category_option_menu.Active = i;
 							return;
 						}
 					}	
@@ -130,8 +139,6 @@ public class TagCommands {
 		
 		public Tag Execute (TagType type, Tag [] selection)
 		{
-			this.CreateDialog ("create_tag_dialog");
-
 			Category default_category = null;
 			if (selection.Length > 0) {
 				if (selection [0] is Category)
@@ -140,9 +147,9 @@ public class TagCommands {
 					default_category = selection [0].Category;
 			}
 
-			this.Dialog.DefaultResponse = ResponseType.Ok;
+			this.DefaultResponse = ResponseType.Ok;
 
-			this.Dialog.Title = Catalog.GetString ("Create New Tag");
+			this.Title = Catalog.GetString ("Create New Tag");
 			prompt_label.Text = Catalog.GetString ("Name of New Tag:");
 			this.auto_icon_checkbutton.Active = Preferences.Get<bool> (Preferences.TAG_ICON_AUTOMATIC);
 
@@ -151,7 +158,7 @@ public class TagCommands {
 			Update ();
 			tag_name_entry.GrabFocus ();
 
-			ResponseType response = (ResponseType) this.Dialog.Run ();
+			ResponseType response = (ResponseType) this.Run ();
 
 
 			Tag new_tag = null;
@@ -171,11 +178,11 @@ public class TagCommands {
 				}
 			}
 
-			this.Dialog.Destroy ();
+			this.Destroy ();
 			return new_tag;
 		}
 
-		public Create (TagStore tag_store, Gtk.Window parent_window)
+		public Create (TagStore tag_store, Gtk.Window parent_window) : base("create_tag_dialog.ui", "create_tag_dialog")
 		{
 			this.tag_store = tag_store;
 			this.parent_window = parent_window;
diff --git a/src/f-spot.glade b/src/f-spot.glade
index a23701e..c2d2db8 100644
--- a/src/f-spot.glade
+++ b/src/f-spot.glade
@@ -4,162 +4,6 @@
 <glade-interface>
   <requires lib="canvas"/>
   <requires lib="gnome"/>
-  <widget class="GtkDialog" id="create_tag_dialog">
-    <property name="border_width">6</property>
-    <property name="modal">True</property>
-    <property name="destroy_with_parent">True</property>
-    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
-    <property name="has_separator">False</property>
-    <child internal-child="vbox">
-      <widget class="GtkVBox" id="vbox1">
-        <property name="visible">True</property>
-        <property name="spacing">2</property>
-        <child>
-          <widget class="GtkTable" id="table1">
-            <property name="visible">True</property>
-            <property name="n_rows">2</property>
-            <property name="n_columns">2</property>
-            <property name="column_spacing">6</property>
-            <property name="row_spacing">6</property>
-            <child>
-              <widget class="GtkLabel" id="category_label">
-                <property name="visible">True</property>
-                <property name="xalign">0</property>
-                <property name="label" translatable="yes">P_arent Tag:</property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">category_option_menu</property>
-              </widget>
-              <packing>
-                <property name="x_options">GTK_FILL</property>
-                <property name="y_options"></property>
-              </packing>
-            </child>
-            <child>
-              <widget class="GtkLabel" id="prompt_label">
-                <property name="visible">True</property>
-                <property name="xalign">0</property>
-                <property name="label" translatable="yes">_Tag Name:</property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">tag_name_entry</property>
-              </widget>
-              <packing>
-                <property name="top_attach">1</property>
-                <property name="bottom_attach">2</property>
-                <property name="x_options">GTK_FILL</property>
-                <property name="y_options"></property>
-              </packing>
-            </child>
-            <child>
-              <widget class="GtkEntry" id="tag_name_entry">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="invisible_char">*</property>
-                <property name="activates_default">True</property>
-                <signal name="changed" handler="HandleTagNameEntryChanged"/>
-              </widget>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="right_attach">2</property>
-                <property name="top_attach">1</property>
-                <property name="bottom_attach">2</property>
-                <property name="y_options"></property>
-              </packing>
-            </child>
-            <child>
-              <widget class="GtkOptionMenu" id="category_option_menu">
-                <property name="width_request">150</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="response_id">0</property>
-              </widget>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="right_attach">2</property>
-                <property name="x_options">GTK_FILL</property>
-                <property name="y_options"></property>
-              </packing>
-            </child>
-          </widget>
-          <packing>
-            <property name="position">1</property>
-          </packing>
-        </child>
-        <child>
-          <widget class="GtkAlignment" id="alignment2">
-            <property name="visible">True</property>
-            <property name="xalign">0</property>
-            <property name="xscale">0</property>
-            <child>
-              <widget class="GtkLabel" id="already_in_use_label">
-                <property name="visible">True</property>
-                <property name="label">&lt;small&gt;&lt;/small&gt;</property>
-                <property name="use_markup">True</property>
-              </widget>
-            </child>
-          </widget>
-          <packing>
-            <property name="fill">False</property>
-            <property name="position">2</property>
-          </packing>
-        </child>
-        <child>
-          <widget class="GtkAlignment" id="alignment3">
-            <property name="visible">True</property>
-            <property name="xalign">0</property>
-            <property name="xscale">0</property>
-            <child>
-              <widget class="GtkCheckButton" id="auto_icon_checkbutton">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="label" translatable="yes">Create _icon for this tag when first used</property>
-                <property name="use_underline">True</property>
-                <property name="response_id">0</property>
-                <property name="draw_indicator">True</property>
-              </widget>
-            </child>
-          </widget>
-          <packing>
-            <property name="fill">False</property>
-            <property name="position">3</property>
-          </packing>
-        </child>
-        <child internal-child="action_area">
-          <widget class="GtkHButtonBox" id="hbuttonbox1">
-            <property name="visible">True</property>
-            <property name="layout_style">GTK_BUTTONBOX_END</property>
-            <child>
-              <widget class="GtkButton" id="cancel_button">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="label">gtk-cancel</property>
-                <property name="use_stock">True</property>
-                <property name="response_id">-6</property>
-              </widget>
-            </child>
-            <child>
-              <widget class="GtkButton" id="create_button">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="label" translatable="yes">C_reate</property>
-                <property name="use_underline">True</property>
-                <property name="response_id">-5</property>
-              </widget>
-              <packing>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </widget>
-          <packing>
-            <property name="expand">False</property>
-            <property name="padding">2</property>
-            <property name="pack_type">GTK_PACK_END</property>
-          </packing>
-        </child>
-      </widget>
-    </child>
-  </widget>
   <widget class="GtkDialog" id="tag_selection_dialog">
     <property name="width_request">300</property>
     <property name="height_request">300</property>
diff --git a/src/ui/create_tag_dialog.ui b/src/ui/create_tag_dialog.ui
new file mode 100644
index 0000000..88c8359
--- /dev/null
+++ b/src/ui/create_tag_dialog.ui
@@ -0,0 +1,169 @@
+<?xml version="1.0"?>
+<interface>
+  <!-- interface-requires gtk+ 2.12 -->
+  <!-- interface-naming-policy toplevel-contextual -->
+  <object class="GtkDialog" id="create_tag_dialog">
+    <property name="border_width">6</property>
+    <property name="modal">True</property>
+    <property name="destroy_with_parent">True</property>
+    <property name="type_hint">dialog</property>
+    <property name="has_separator">False</property>
+    <child internal-child="vbox">
+      <object class="GtkVBox" id="vbox1">
+        <property name="visible">True</property>
+        <property name="spacing">2</property>
+        <child>
+          <object class="GtkTable" id="table1">
+            <property name="visible">True</property>
+            <property name="n_rows">2</property>
+            <property name="n_columns">2</property>
+            <property name="column_spacing">6</property>
+            <property name="row_spacing">6</property>
+            <child>
+              <object class="GtkLabel" id="category_label">
+                <property name="visible">True</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">P_arent Tag:</property>
+                <property name="use_underline">True</property>
+              </object>
+              <packing>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="prompt_label">
+                <property name="visible">True</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">_Tag Name:</property>
+                <property name="use_underline">True</property>
+                <property name="mnemonic_widget">tag_name_entry</property>
+              </object>
+              <packing>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkEntry" id="tag_name_entry">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="activates_default">True</property>
+                <signal name="changed" handler="HandleTagNameEntryChanged"/>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkComboBox" id="category_option_menu">
+                <property name="width_request">150</property>
+                <property name="visible">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkAlignment" id="alignment2">
+            <property name="visible">True</property>
+            <property name="xalign">0</property>
+            <property name="xscale">0</property>
+            <child>
+              <object class="GtkLabel" id="already_in_use_label">
+                <property name="visible">True</property>
+                <property name="label">&lt;small&gt;&lt;/small&gt;</property>
+                <property name="use_markup">True</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="fill">False</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkAlignment" id="alignment3">
+            <property name="visible">True</property>
+            <property name="xalign">0</property>
+            <property name="xscale">0</property>
+            <child>
+              <object class="GtkCheckButton" id="auto_icon_checkbutton">
+                <property name="label" translatable="yes">Create _icon for this tag when first used</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="use_underline">True</property>
+                <property name="draw_indicator">True</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="fill">False</property>
+            <property name="position">3</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <object class="GtkHButtonBox" id="hbuttonbox1">
+            <property name="visible">True</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="cancel_button">
+                <property name="label">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="receives_default">False</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="create_button">
+                <property name="label" translatable="yes">C_reate</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="receives_default">False</property>
+                <property name="use_underline">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="padding">2</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-6">cancel_button</action-widget>
+      <action-widget response="-5">create_button</action-widget>
+    </action-widgets>
+  </object>
+</interface>



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