[gthumb: 1/2] organize the extensions in categories



commit f08a06d68a105a1088e8a8e13a3cd08f369fac1d
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sat Mar 13 19:07:30 2010 +0100

    organize the extensions in categories

 data/ui/extensions.ui                              |  162 +++++++++++++++----
 extensions/bookmarks/bookmarks.extension.in.in     |    1 +
 extensions/burn_disc/burn_disc.extension.in.in     |    1 +
 extensions/catalogs/catalogs.extension.in.in       |    1 +
 extensions/change_date/change_date.extension.in.in |    1 +
 extensions/comments/comments.extension.in.in       |    1 +
 .../convert_format/convert_format.extension.in.in  |    1 +
 .../desktop_background.extension.in.in             |    1 +
 .../edit_metadata/edit_metadata.extension.in.in    |    1 +
 extensions/exiv2_tools/exiv2_tools.extension.in.in |    1 +
 .../file_manager/file_manager.extension.in.in      |    1 +
 extensions/file_tools/file_tools.extension.in.in   |    1 +
 extensions/flicker/flicker.extension.in.in         |    1 +
 .../gstreamer_tools.extension.in.in                |    1 +
 extensions/image_print/image_print.extension.in.in |    1 +
 .../image_rotation/image_rotation.extension.in.in  |    1 +
 .../image_viewer/image_viewer.extension.in.in      |    1 +
 extensions/list_tools/list_tools.extension.in.in   |    1 +
 .../photo_importer/photo_importer.extension.in.in  |    1 +
 extensions/picasaweb/picasaweb.extension.in.in     |    1 +
 .../pixbuf_savers/pixbuf_savers.extension.in.in    |    1 +
 extensions/raw_files/raw_files.extension.in.in     |    1 +
 .../red_eye_removal.extension.in.in                |    1 +
 .../rename_series/rename_series.extension.in.in    |    1 +
 .../resize_images/resize_images.extension.in.in    |    1 +
 extensions/search/search.extension.in.in           |    1 +
 extensions/slideshow/slideshow.extension.in.in     |    1 +
 gthumb/dlg-extensions.c                            |  148 +++++++++++++++++-
 gthumb/gth-extensions.c                            |    2 +
 gthumb/gth-extensions.h                            |    1 +
 30 files changed, 297 insertions(+), 42 deletions(-)
---
diff --git a/data/ui/extensions.ui b/data/ui/extensions.ui
index bba86c1..f5ec383 100644
--- a/data/ui/extensions.ui
+++ b/data/ui/extensions.ui
@@ -15,7 +15,7 @@
         <child>
           <object class="GtkHBox" id="hbox1">
             <property name="visible">True</property>
-            <property name="border_width">6</property>
+            <property name="border_width">5</property>
             <property name="spacing">12</property>
             <child>
               <object class="GtkVBox" id="vbox1">
@@ -23,65 +23,147 @@
                 <property name="orientation">vertical</property>
                 <property name="spacing">6</property>
                 <child>
-                  <object class="GtkLabel" id="extensions_label">
+                  <object class="GtkHPaned" id="hpaned1">
                     <property name="visible">True</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes">Available _extensions:</property>
-                    <property name="use_underline">True</property>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkVBox" id="vbox2">
-                    <property name="visible">True</property>
-                    <property name="orientation">vertical</property>
-                    <property name="spacing">3</property>
+                    <property name="can_focus">True</property>
                     <child>
-                      <object class="GtkScrolledWindow" id="extensions_scrolledwindow">
-                        <property name="width_request">350</property>
-                        <property name="height_request">350</property>
+                      <object class="GtkVBox" id="vbox3">
                         <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="hscrollbar_policy">automatic</property>
-                        <property name="vscrollbar_policy">automatic</property>
-                        <property name="shadow_type">in</property>
+                        <property name="orientation">vertical</property>
+                        <property name="spacing">6</property>
+                        <child>
+                          <object class="GtkLabel" id="label1">
+                            <property name="visible">True</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="yes">_Categories:</property>
+                            <property name="use_underline">True</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
                         <child>
-                          <placeholder/>
+                          <object class="GtkScrolledWindow" id="scrolledwindow1">
+                            <property name="width_request">120</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="hscrollbar_policy">automatic</property>
+                            <property name="vscrollbar_policy">automatic</property>
+                            <property name="shadow_type">in</property>
+                            <child>
+                              <object class="GtkTreeView" id="category_treeview">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="model">category_liststore</property>
+                                <property name="headers_visible">False</property>
+                                <property name="enable_search">False</property>
+                                <child>
+                                  <object class="GtkTreeViewColumn" id="treeviewcolumn1">
+                                    <property name="sort_column_id">0</property>
+                                    <child>
+                                      <object class="GtkCellRendererPixbuf" id="cellrenderertext1"/>
+                                      <attributes>
+                                        <attribute name="icon-name">2</attribute>
+                                      </attributes>
+                                    </child>
+                                    <child>
+                                      <object class="GtkCellRendererText" id="cellrendererpixbuf1"/>
+                                      <attributes>
+                                        <attribute name="text">1</attribute>
+                                      </attributes>
+                                    </child>
+                                  </object>
+                                </child>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="position">1</property>
+                          </packing>
                         </child>
                       </object>
                       <packing>
-                        <property name="position">0</property>
+                        <property name="resize">False</property>
+                        <property name="shrink">False</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkHBox" id="hbox2">
+                      <object class="GtkVBox" id="vbox2">
                         <property name="visible">True</property>
+                        <property name="orientation">vertical</property>
+                        <property name="spacing">6</property>
                         <child>
-                          <object class="GtkLinkButton" id="linkbutton1">
-                            <property name="label" translatable="yes">More extensions...</property>
+                          <object class="GtkLabel" id="extensions_label">
                             <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="receives_default">True</property>
-                            <property name="relief">none</property>
-                            <property name="uri">http://live.gnome.org/gthumb/extensions</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="yes">Available _extensions:</property>
+                            <property name="use_underline">True</property>
                           </object>
                           <packing>
                             <property name="expand">False</property>
+                            <property name="fill">False</property>
                             <property name="position">0</property>
                           </packing>
                         </child>
+                        <child>
+                          <object class="GtkVBox" id="vbox4">
+                            <property name="visible">True</property>
+                            <property name="orientation">vertical</property>
+                            <property name="spacing">3</property>
+                            <child>
+                              <object class="GtkScrolledWindow" id="extensions_scrolledwindow">
+                                <property name="width_request">350</property>
+                                <property name="height_request">350</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="hscrollbar_policy">automatic</property>
+                                <property name="vscrollbar_policy">automatic</property>
+                                <property name="shadow_type">in</property>
+                                <child>
+                                  <placeholder/>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="resize">False</property>
+                        <property name="shrink">True</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkHBox" id="hbox2">
+                    <property name="visible">True</property>
+                    <child>
+                      <object class="GtkLinkButton" id="linkbutton1">
+                        <property name="label" translatable="yes">More extensions...</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">True</property>
+                        <property name="relief">none</property>
+                        <property name="uri">http://live.gnome.org/gthumb/extensions</property>
                       </object>
                       <packing>
                         <property name="expand">False</property>
-                        <property name="position">1</property>
+                        <property name="position">0</property>
                       </packing>
                     </child>
                   </object>
                   <packing>
+                    <property name="expand">False</property>
                     <property name="position">1</property>
                   </packing>
                 </child>
@@ -159,4 +241,16 @@
       <action-widget response="0">close_button</action-widget>
     </action-widgets>
   </object>
+  <object class="GtkListStore" id="category_liststore">
+    <columns>
+      <!-- column-name id -->
+      <column type="gchararray"/>
+      <!-- column-name name -->
+      <column type="gchararray"/>
+      <!-- column-name icon -->
+      <column type="gchararray"/>
+      <!-- column-name separator -->
+      <column type="gboolean"/>
+    </columns>
+  </object>
 </interface>
diff --git a/extensions/bookmarks/bookmarks.extension.in.in b/extensions/bookmarks/bookmarks.extension.in.in
index 52b43ae..f598676 100644
--- a/extensions/bookmarks/bookmarks.extension.in.in
+++ b/extensions/bookmarks/bookmarks.extension.in.in
@@ -5,6 +5,7 @@ _Authors=Paolo Bacchilega <paobac src gnome org>
 Copyright=Copyright © 2008-2009 The Free Software Foundation, Inc.
 Version=1.0
 URL=http://live.gnome.org/gthumb
+Category=Browser
 
 [Loader]
 Type=module
diff --git a/extensions/burn_disc/burn_disc.extension.in.in b/extensions/burn_disc/burn_disc.extension.in.in
index 248d236..69330a8 100644
--- a/extensions/burn_disc/burn_disc.extension.in.in
+++ b/extensions/burn_disc/burn_disc.extension.in.in
@@ -5,6 +5,7 @@ _Authors=gthumb development team
 Copyright=Copyright © 2010 The Free Software Foundation, Inc.
 Version=1.0
 Icon=brasero
+Category=Exporter
 
 [Loader]
 Type=module
diff --git a/extensions/catalogs/catalogs.extension.in.in b/extensions/catalogs/catalogs.extension.in.in
index fcb899e..3049ed1 100644
--- a/extensions/catalogs/catalogs.extension.in.in
+++ b/extensions/catalogs/catalogs.extension.in.in
@@ -6,6 +6,7 @@ Copyright=Copyright © 2008-2010 The Free Software Foundation, Inc.
 Version=1.0
 URL=http://live.gnome.org/gthumb
 Icon=file-catalog
+Category=Browser
 
 [Loader]
 Type=module
diff --git a/extensions/change_date/change_date.extension.in.in b/extensions/change_date/change_date.extension.in.in
index 42b145f..8b0be3f 100644
--- a/extensions/change_date/change_date.extension.in.in
+++ b/extensions/change_date/change_date.extension.in.in
@@ -4,6 +4,7 @@ _Description=Change the files date
 _Authors=gthumb development team
 Copyright=Copyright © 2010 The Free Software Foundation, Inc.
 Version=1.0
+Category=List-Tool
 
 [Loader]
 Type=module
diff --git a/extensions/comments/comments.extension.in.in b/extensions/comments/comments.extension.in.in
index 285611c..0cfabc6 100644
--- a/extensions/comments/comments.extension.in.in
+++ b/extensions/comments/comments.extension.in.in
@@ -4,6 +4,7 @@ _Description=Add comments and tags to any file type.
 _Authors=gthumb development team
 Copyright=Copyright © 2009 The Free Software Foundation, Inc.
 Version=1.0
+Category=Metadata
 
 [Loader]
 Type=module
diff --git a/extensions/convert_format/convert_format.extension.in.in b/extensions/convert_format/convert_format.extension.in.in
index 5874db5..ae81738 100644
--- a/extensions/convert_format/convert_format.extension.in.in
+++ b/extensions/convert_format/convert_format.extension.in.in
@@ -4,6 +4,7 @@ _Description=Save images in a different format
 _Authors=gthumb development team
 Copyright=Copyright © 2010 The Free Software Foundation, Inc.
 Version=1.0
+Category=List-Tool
 
 [Loader]
 Type=module
diff --git a/extensions/desktop_background/desktop_background.extension.in.in b/extensions/desktop_background/desktop_background.extension.in.in
index 11b9ad0..ee7734f 100644
--- a/extensions/desktop_background/desktop_background.extension.in.in
+++ b/extensions/desktop_background/desktop_background.extension.in.in
@@ -5,6 +5,7 @@ _Authors=gthumb development team
 Copyright=Copyright © 2009 The Free Software Foundation, Inc.
 Version=1.0
 Icon=desktop
+Category=List-Tool
 
 [Loader]
 Type=module
diff --git a/extensions/edit_metadata/edit_metadata.extension.in.in b/extensions/edit_metadata/edit_metadata.extension.in.in
index 52f69c4..da42d99 100644
--- a/extensions/edit_metadata/edit_metadata.extension.in.in
+++ b/extensions/edit_metadata/edit_metadata.extension.in.in
@@ -5,6 +5,7 @@ _Authors=gthumb development team
 Copyright=Copyright © 2009-2010 The Free Software Foundation, Inc.
 Version=1.0
 URL=http://live.gnome.org/gthumb
+Category=Metadata
 
 [Loader]
 Type=module
diff --git a/extensions/exiv2_tools/exiv2_tools.extension.in.in b/extensions/exiv2_tools/exiv2_tools.extension.in.in
index 4af73d2..90b9da8 100644
--- a/extensions/exiv2_tools/exiv2_tools.extension.in.in
+++ b/extensions/exiv2_tools/exiv2_tools.extension.in.in
@@ -4,6 +4,7 @@ _Description=Read and write exif, iptc and xmp metadata.
 _Authors=gthumb development team
 Copyright=Copyright © 2009 The Free Software Foundation, Inc.
 Version=1.0
+Category=Metadata
 
 [Loader]
 Type=module
diff --git a/extensions/file_manager/file_manager.extension.in.in b/extensions/file_manager/file_manager.extension.in.in
index 174f09c..66a24f5 100644
--- a/extensions/file_manager/file_manager.extension.in.in
+++ b/extensions/file_manager/file_manager.extension.in.in
@@ -5,6 +5,7 @@ _Authors=gthumb development team
 Copyright=Copyright © 2009 The Free Software Foundation, Inc.
 Version=1.0
 Icon=system-file-manager
+Category=Browser
 
 [Loader]
 Type=module
diff --git a/extensions/file_tools/file_tools.extension.in.in b/extensions/file_tools/file_tools.extension.in.in
index 7e2d95f..a81ac6f 100644
--- a/extensions/file_tools/file_tools.extension.in.in
+++ b/extensions/file_tools/file_tools.extension.in.in
@@ -5,6 +5,7 @@ _Authors=gthumb development team
 Copyright=Copyright © 2009 The Free Software Foundation, Inc.
 Version=1.0
 Icon=palette
+Category=File-Tool
 
 [Loader]
 Type=module
diff --git a/extensions/flicker/flicker.extension.in.in b/extensions/flicker/flicker.extension.in.in
index 27a09ae..9030291 100644
--- a/extensions/flicker/flicker.extension.in.in
+++ b/extensions/flicker/flicker.extension.in.in
@@ -5,6 +5,7 @@ Authors=gthumb development team
 Copyright=Copyright © 2010 The Free Software Foundation, Inc.
 Version=1.0
 Icon=flickr
+Category=Exporter
 
 [Loader]
 Type=module
diff --git a/extensions/gstreamer_tools/gstreamer_tools.extension.in.in b/extensions/gstreamer_tools/gstreamer_tools.extension.in.in
index 6573788..33b3d02 100644
--- a/extensions/gstreamer_tools/gstreamer_tools.extension.in.in
+++ b/extensions/gstreamer_tools/gstreamer_tools.extension.in.in
@@ -5,6 +5,7 @@ _Authors=gthumb development team
 Copyright=Copyright © 2009-2010 The Free Software Foundation, Inc.
 Version=1.0
 Icon=video-x-generic
+Category=Viewer
 
 [Loader]
 Type=module
diff --git a/extensions/image_print/image_print.extension.in.in b/extensions/image_print/image_print.extension.in.in
index dd25053..64e9f5e 100644
--- a/extensions/image_print/image_print.extension.in.in
+++ b/extensions/image_print/image_print.extension.in.in
@@ -5,6 +5,7 @@ _Authors=gthumb development team
 Copyright=Copyright © 2009 The Free Software Foundation, Inc.
 Version=1.0
 Icon=document-print
+Category=List-Tool
 
 [Loader]
 Type=module
diff --git a/extensions/image_rotation/image_rotation.extension.in.in b/extensions/image_rotation/image_rotation.extension.in.in
index 827c2d4..98d83ee 100644
--- a/extensions/image_rotation/image_rotation.extension.in.in
+++ b/extensions/image_rotation/image_rotation.extension.in.in
@@ -4,6 +4,7 @@ _Description=Rotate images without data loss.
 _Authors=gthumb development team
 Copyright=Copyright © 2009 The Free Software Foundation, Inc.
 Version=1.0
+Category=List-Tool
 
 [Loader]
 Type=module
diff --git a/extensions/image_viewer/image_viewer.extension.in.in b/extensions/image_viewer/image_viewer.extension.in.in
index 86ac261..75cb00f 100644
--- a/extensions/image_viewer/image_viewer.extension.in.in
+++ b/extensions/image_viewer/image_viewer.extension.in.in
@@ -5,6 +5,7 @@ _Authors=gthumb development team
 Copyright=Copyright © 2009 The Free Software Foundation, Inc.
 Version=1.0
 Icon=image-x-generic
+Category=Viewer
 
 [Loader]
 After=file_viewer
diff --git a/extensions/list_tools/list_tools.extension.in.in b/extensions/list_tools/list_tools.extension.in.in
index f9cfcce..d26d1c7 100644
--- a/extensions/list_tools/list_tools.extension.in.in
+++ b/extensions/list_tools/list_tools.extension.in.in
@@ -5,6 +5,7 @@ _Authors=gthumb development team
 Copyright=Copyright © 2009 The Free Software Foundation, Inc.
 Version=1.0
 Icon=applications-engineering
+Category=List-Tool
 
 [Loader]
 Type=module
diff --git a/extensions/photo_importer/photo_importer.extension.in.in b/extensions/photo_importer/photo_importer.extension.in.in
index 28b863f..1d95d70 100644
--- a/extensions/photo_importer/photo_importer.extension.in.in
+++ b/extensions/photo_importer/photo_importer.extension.in.in
@@ -5,6 +5,7 @@ _Authors=gthumb development team
 Copyright=Copyright © 2009 The Free Software Foundation, Inc.
 Version=1.0
 Icon=camera-photo
+Category=Importer
 
 [Loader]
 Type=module
diff --git a/extensions/picasaweb/picasaweb.extension.in.in b/extensions/picasaweb/picasaweb.extension.in.in
index 5cd8a23..1c85e97 100644
--- a/extensions/picasaweb/picasaweb.extension.in.in
+++ b/extensions/picasaweb/picasaweb.extension.in.in
@@ -5,6 +5,7 @@ Authors=gthumb development team
 Copyright=Copyright © 2010 The Free Software Foundation, Inc.
 Version=1.0
 Icon=picasaweb
+Category=Exporter
 
 [Loader]
 Type=module
diff --git a/extensions/pixbuf_savers/pixbuf_savers.extension.in.in b/extensions/pixbuf_savers/pixbuf_savers.extension.in.in
index 032c973..19097a7 100644
--- a/extensions/pixbuf_savers/pixbuf_savers.extension.in.in
+++ b/extensions/pixbuf_savers/pixbuf_savers.extension.in.in
@@ -4,6 +4,7 @@ _Description=Save images in common file formats such as JPEG, PNG and TIFF
 _Authors=gthumb development team
 Copyright=Copyright © 2009 The Free Software Foundation, Inc.
 Version=1.0
+Category=Browser
 
 [Loader]
 Type=module
diff --git a/extensions/raw_files/raw_files.extension.in.in b/extensions/raw_files/raw_files.extension.in.in
index 5f38bf1..416756d 100644
--- a/extensions/raw_files/raw_files.extension.in.in
+++ b/extensions/raw_files/raw_files.extension.in.in
@@ -4,6 +4,7 @@ _Description=Allow to load raw format images.
 _Authors=gthumb development team
 Copyright=Copyright © 2009 The Free Software Foundation, Inc.
 Version=1.0
+Category=Viewer
 
 [Loader]
 Type=module
diff --git a/extensions/red_eye_removal/red_eye_removal.extension.in.in b/extensions/red_eye_removal/red_eye_removal.extension.in.in
index 1e5b8f6..981214f 100644
--- a/extensions/red_eye_removal/red_eye_removal.extension.in.in
+++ b/extensions/red_eye_removal/red_eye_removal.extension.in.in
@@ -4,6 +4,7 @@ _Description=Tool to remove the red-eye effect from a photo.
 _Authors=gthumb development team
 Copyright=Copyright © 2009 The Free Software Foundation, Inc.
 Version=1.0
+Category=File-Tool
 
 [Loader]
 Type=module
diff --git a/extensions/rename_series/rename_series.extension.in.in b/extensions/rename_series/rename_series.extension.in.in
index 9481ec1..1b38258 100644
--- a/extensions/rename_series/rename_series.extension.in.in
+++ b/extensions/rename_series/rename_series.extension.in.in
@@ -4,6 +4,7 @@ _Description=Rename series of files.
 _Authors=gthumb development team
 Copyright=Copyright © 2009 The Free Software Foundation, Inc.
 Version=1.0
+Category=List-Tool
 
 [Loader]
 Type=module
diff --git a/extensions/resize_images/resize_images.extension.in.in b/extensions/resize_images/resize_images.extension.in.in
index 6e23681..bc92b66 100644
--- a/extensions/resize_images/resize_images.extension.in.in
+++ b/extensions/resize_images/resize_images.extension.in.in
@@ -4,6 +4,7 @@ _Description=Resize series of images.
 _Authors=gthumb development team
 Copyright=Copyright © 2009 The Free Software Foundation, Inc.
 Version=1.0
+Category=List-Tool
 
 [Loader]
 Type=module
diff --git a/extensions/search/search.extension.in.in b/extensions/search/search.extension.in.in
index 028b8c8..d77d80b 100644
--- a/extensions/search/search.extension.in.in
+++ b/extensions/search/search.extension.in.in
@@ -5,6 +5,7 @@ _Authors=gthumb development team
 Copyright=Copyright © 2008-2009 The Free Software Foundation, Inc.
 Version=1.0
 Icon=edit-find
+Category=Browser
 
 [Loader]
 Type=module
diff --git a/extensions/slideshow/slideshow.extension.in.in b/extensions/slideshow/slideshow.extension.in.in
index de7672c..d12ecb6 100644
--- a/extensions/slideshow/slideshow.extension.in.in
+++ b/extensions/slideshow/slideshow.extension.in.in
@@ -5,6 +5,7 @@ _Authors=gthumb development team
 Copyright=Copyright © 2008-2009 The Free Software Foundation, Inc.
 Version=1.0
 Icon=x-office-presentation
+Category=Browser
 
 [Loader]
 Type=module
diff --git a/gthumb/dlg-extensions.c b/gthumb/dlg-extensions.c
index dfa95e8..969222c 100644
--- a/gthumb/dlg-extensions.c
+++ b/gthumb/dlg-extensions.c
@@ -35,13 +35,46 @@
 #define DEFAULT_ICON "application-x-executable"
 
 
+enum {
+	CATEGORY_ID_COLUMN,
+	CATEGORY_NAME_COLUMN,
+	CATEGORY_ICON_COLUMN,
+	CATEGORY_SEPARATOR_COLUMN
+};
+
+
+typedef struct {
+	const char *id;
+	const char *name;
+	const char *icon;
+} ExtensionCategory;
+
+
+static ExtensionCategory extension_category[] = {
+		{ "*", N_("All"), "folder" },
+		{ "+", N_("Enabled"), "folder" },
+		{ "-", N_("Disabled"), "folder" },
+		{ "---", NULL, NULL },
+		{ "Browser", N_("Browser"), "folder" },
+		{ "Viewer", N_("Viewers"), "folder" },
+		{ "Metadata", N_("Metadata"), "folder" },
+		{ "File-Tool", N_("File tools"), "folder" },
+		{ "List-Tool", N_("List tools"), "folder" },
+		{ "Importer", N_("Importers"), "folder" },
+		{ "Exporter", N_("Exporters"), "folder" },
+		{ NULL, NULL, NULL }
+};
+
+
 typedef struct {
 	GthBrowser   *browser;
 	GtkBuilder   *builder;
 	GtkWidget    *dialog;
 	GtkWidget    *list_view;
 	GtkListStore *list_store;
+	GtkTreeModel *model_filter;
 	GSList       *active_extensions;
+	char         *current_category;
 } DialogData;
 
 
@@ -124,6 +157,7 @@ destroy_cb (GtkWidget  *widget,
 	g_slist_foreach (data->active_extensions, (GFunc) g_free, NULL);
 	g_slist_free (data->active_extensions);
 	g_object_unref (data->builder);
+	g_free (data->current_category);
 	g_free (data);
 }
 
@@ -198,22 +232,24 @@ cell_renderer_toggle_toggled_cb (GtkCellRendererToggle *cell_renderer,
 	if (tree_path == NULL)
 		return;
 
-	if (gtk_tree_model_get_iter (GTK_TREE_MODEL (data->list_store), &iter, tree_path)) {
+	if (gtk_tree_model_get_iter (GTK_TREE_MODEL (data->model_filter), &iter, tree_path)) {
 		GthExtensionDescription *description;
 		GError                  *error = NULL;
+		GtkTreeIter              child_iter;
 
-		gtk_tree_model_get (GTK_TREE_MODEL (data->list_store), &iter, 0, &description, -1);
+		gtk_tree_model_get (GTK_TREE_MODEL (data->model_filter), &iter, 0, &description, -1);
+		gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (data->model_filter), &child_iter, &iter);
 		if (! gth_extension_description_is_active (description)) {
 			if (! gth_extension_manager_activate (gth_main_get_default_extension_manager (), description->id, &error))
 				_gtk_error_dialog_from_gerror_run (GTK_WINDOW (data->dialog), _("Could not activate the extension"), &error);
 			else
-				gtk_list_store_set (data->list_store, &iter, 0, description, -1);
+				gtk_list_store_set (data->list_store, &child_iter, 0, description, -1);
 		}
 		else {
 			if (! gth_extension_manager_deactivate (gth_main_get_default_extension_manager (), description->id, &error))
 				_gtk_error_dialog_from_gerror_run (GTK_WINDOW (data->dialog), _("Could not deactivate the extension"), &error);
 			else
-				gtk_list_store_set (data->list_store, &iter, 0, description, -1);
+				gtk_list_store_set (data->list_store, &child_iter, 0, description, -1);
 		}
 
 		g_object_unref (description);
@@ -298,7 +334,7 @@ list_view_selection_changed_cb (GtkTreeSelection *treeselection,
 	GthExtensionDescription *description;
 	GthExtension            *extension;
 
-	model = GTK_TREE_MODEL (data->list_store);
+	model = GTK_TREE_MODEL (data->model_filter);
 	if (! gtk_tree_selection_get_selected (treeselection, &model, &iter))
 		return;
 
@@ -312,6 +348,25 @@ list_view_selection_changed_cb (GtkTreeSelection *treeselection,
 
 
 static void
+category_treeview_selection_changed_cb (GtkTreeSelection *treeselection,
+					gpointer          user_data)
+{
+	DialogData   *data = user_data;
+	GtkTreeModel *model;
+	GtkTreeIter   iter;
+
+	model = GTK_TREE_MODEL (data->model_filter);
+	if (! gtk_tree_selection_get_selected (treeselection, &model, &iter))
+		return;
+
+	g_free (data->current_category);
+	gtk_tree_model_get (model, &iter, 0, &data->current_category, -1);
+
+	gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (data->model_filter));
+}
+
+
+static void
 about_button_clicked_cb (GtkButton *button,
 			 gpointer   user_data)
 {
@@ -321,7 +376,7 @@ about_button_clicked_cb (GtkButton *button,
 	GthExtensionDescription *description;
 	GtkWidget               *dialog;
 
-	model = GTK_TREE_MODEL (data->list_store);
+	model = GTK_TREE_MODEL (data->model_filter);
 	if (! gtk_tree_selection_get_selected (gtk_tree_view_get_selection (GTK_TREE_VIEW (data->list_view)), &model, &iter))
 		return;
 
@@ -363,7 +418,7 @@ preferences_button_clicked_cb (GtkButton *button,
 	GthExtensionDescription *description;
 	GthExtension            *extension;
 
-	model = GTK_TREE_MODEL (data->list_store);
+	model = GTK_TREE_MODEL (data->model_filter);
 	if (! gtk_tree_selection_get_selected (gtk_tree_view_get_selection (GTK_TREE_VIEW (data->list_view)), &model, &iter))
 		return;
 
@@ -375,6 +430,44 @@ preferences_button_clicked_cb (GtkButton *button,
 }
 
 
+static gboolean
+category_view_separator_func (GtkTreeModel *model,
+			      GtkTreeIter  *iter,
+			      gpointer      data)
+{
+	gboolean separator;
+
+	gtk_tree_model_get (model, iter, CATEGORY_SEPARATOR_COLUMN, &separator, -1);
+	return separator;
+}
+
+
+static gboolean
+category_model_visible_func (GtkTreeModel *model,
+			     GtkTreeIter  *iter,
+			     gpointer      user_data)
+{
+	DialogData              *data = user_data;
+	GthExtensionDescription *description;
+	gboolean                 visible;
+
+	if (strcmp (data->current_category, "*") == 0)
+		return TRUE;
+
+	gtk_tree_model_get (model, iter, 0, &description, -1);
+
+	visible = FALSE;
+	if ((strcmp (data->current_category, "+") == 0) && gth_extension_description_is_active (description))
+		visible = TRUE;
+	else if ((strcmp (data->current_category, "-") == 0) && ! gth_extension_description_is_active (description))
+		visible = TRUE;
+	else
+		visible = g_strcmp0 (description->category, data->current_category) == 0;
+
+	return visible;
+}
+
+
 void
 dlg_extensions (GthBrowser *browser)
 {
@@ -383,6 +476,7 @@ dlg_extensions (GthBrowser *browser)
 	GList               *extensions;
 	GList               *scan;
 	GtkTreePath         *first;
+	int                  i;
 
 	if (gth_browser_get_dialog (browser, "extensions") != NULL) {
 		gtk_window_present (GTK_WINDOW (gth_browser_get_dialog (browser, "extensions")));
@@ -403,7 +497,9 @@ dlg_extensions (GthBrowser *browser)
 	/* Set widgets data. */
 
 	data->list_store = gtk_list_store_new (1, G_TYPE_OBJECT);
-	data->list_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (data->list_store));
+	data->model_filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (data->list_store), NULL);
+	data->list_view = gtk_tree_view_new_with_model (data->model_filter);
+	g_object_unref (data->model_filter);
 	g_object_unref (data->list_store);
         gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (data->list_view), TRUE);
         gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (data->list_view), TRUE);
@@ -434,6 +530,37 @@ dlg_extensions (GthBrowser *browser)
 	}
 	g_list_free (extensions);
 
+	/* the category list */
+
+	data->current_category = g_strdup ("*");
+	gtk_tree_selection_set_mode (GTK_TREE_SELECTION (gtk_tree_view_get_selection (GTK_TREE_VIEW (GET_WIDGET ("category_treeview")))), GTK_SELECTION_BROWSE);
+	for (i = 0; extension_category[i].id != NULL; i++) {
+		GtkTreeIter iter;
+
+		gtk_list_store_append (GTK_LIST_STORE (GET_WIDGET ("category_liststore")), &iter);
+		if (strcmp (extension_category[i].id, "---") == 0)
+			gtk_list_store_set (GTK_LIST_STORE (GET_WIDGET ("category_liststore")),
+					    &iter,
+					    CATEGORY_SEPARATOR_COLUMN, TRUE,
+					    -1);
+		else
+			gtk_list_store_set (GTK_LIST_STORE (GET_WIDGET ("category_liststore")),
+					    &iter,
+					    CATEGORY_NAME_COLUMN, _(extension_category[i].name),
+					    CATEGORY_ID_COLUMN, extension_category[i].id,
+					    /* CATEGORY_ICON_COLUMN, extension_category[i].icon, */
+					    CATEGORY_SEPARATOR_COLUMN, FALSE,
+					    -1);
+	}
+	gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW (GET_WIDGET ("category_treeview")),
+					      category_view_separator_func,
+					      data,
+					      NULL);
+	gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (data->model_filter),
+						category_model_visible_func,
+						data,
+						NULL);
+
 	/* Set the signals handlers. */
 
 	g_signal_connect (G_OBJECT (data->dialog),
@@ -456,6 +583,11 @@ dlg_extensions (GthBrowser *browser)
 			  "changed",
 			  G_CALLBACK (list_view_selection_changed_cb),
 			  data);
+	g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (GET_WIDGET ("category_treeview"))),
+			  "changed",
+			  G_CALLBACK (category_treeview_selection_changed_cb),
+			  data);
+
 	first = gtk_tree_path_new_first ();
 	gtk_tree_selection_select_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (data->list_view)), first);
 	gtk_tree_path_free (first);
diff --git a/gthumb/gth-extensions.c b/gthumb/gth-extensions.c
index 0493967..99cda77 100644
--- a/gthumb/gth-extensions.c
+++ b/gthumb/gth-extensions.c
@@ -460,6 +460,7 @@ gth_extension_description_finalize (GObject *obj)
 	g_free (self->version);
 	g_free (self->icon_name);
 	g_free (self->url);
+	g_free (self->category);
 	g_free (self->loader_type);
 	g_free (self->loader_file);
 	g_strfreev (self->loader_requires);
@@ -534,6 +535,7 @@ gth_extension_description_load_from_file (GthExtensionDescription *desc,
 	desc->copyright = g_key_file_get_locale_string (key_file, "Extension", "Copyright", NULL, NULL);
 	desc->icon_name = g_key_file_get_string (key_file, "Extension", "Icon", NULL);
 	desc->url = g_key_file_get_string (key_file, "Extension", "URL", NULL);
+	desc->category = g_key_file_get_string (key_file, "Extension", "Category", NULL);
 	desc->mandatory = g_key_file_get_boolean (key_file, "Extension", "Mandatory", NULL);
 	desc->hidden = g_key_file_get_boolean (key_file, "Extension", "Hidden", NULL);
 	desc->loader_type = g_key_file_get_string (key_file, "Loader", "Type", NULL);
diff --git a/gthumb/gth-extensions.h b/gthumb/gth-extensions.h
index f03c37d..9c0f85c 100644
--- a/gthumb/gth-extensions.h
+++ b/gthumb/gth-extensions.h
@@ -115,6 +115,7 @@ struct _GthExtensionDescription {
 	char      *version;
 	char      *icon_name;
 	char      *url;
+	char      *category;
 	char      *loader_type;
 	char      *loader_file;
 	char     **loader_requires;



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