[anjuta/newproject] Add dialog for adding packages and modules



commit 844f91267f45fca4c7484d4bd0da9ea1b102ce5f
Author: Sébastien Granjoux <seb sfo free fr>
Date:   Sun Mar 21 22:57:15 2010 +0100

    Add dialog for adding packages and modules

 plugins/am-project/am-dialogs.c                    |   12 +-
 plugins/am-project/am-project.ui                   |  361 ++-------------
 plugins/project-manager/Makefile.am                |    4 +-
 plugins/project-manager/anjuta-project-manager.xml |    4 +
 plugins/project-manager/create_dialogs.ui          |  442 ++++++++++++++++--
 plugins/project-manager/gbf-project-model.c        |    2 +-
 plugins/project-manager/gbf-project-util.c         |  485 +++++++++++++++++++-
 plugins/project-manager/gbf-project-util.h         |   11 +
 plugins/project-manager/gbf-project-view.c         |   18 +
 plugins/project-manager/gbf-tree-data.c            |    6 +
 plugins/project-manager/gbf-tree-data.h            |    1 +
 plugins/project-manager/plugin.c                   |   82 ++++
 12 files changed, 1067 insertions(+), 361 deletions(-)
---
diff --git a/plugins/am-project/am-dialogs.c b/plugins/am-project/am-dialogs.c
index 9bb3a40..9ae6799 100644
--- a/plugins/am-project/am-dialogs.c
+++ b/plugins/am-project/am-dialogs.c
@@ -181,7 +181,6 @@ GtkWidget *
 amp_configure_project_dialog (AmpProject *project, GError **error)
 {
 	GtkBuilder *bxml = gtk_builder_new ();
-	GtkWidget *top_level;
 	AmpConfigureProjectDialog *dlg;
 	GtkWidget *table;
 	gint pos;
@@ -194,12 +193,11 @@ amp_configure_project_dialog (AmpProject *project, GError **error)
 
 	dlg = g_new0 (AmpConfigureProjectDialog, 1);
 	anjuta_util_builder_get_objects (bxml,
-	                                "top_level", &top_level,
 	    							"general_properties_table", &table,
 	                                NULL);
-	dlg->top_level = top_level;
-	g_object_ref (top_level);
-	g_signal_connect (top_level, "destroy", G_CALLBACK (on_project_widget_destroy), dlg);
+	dlg->top_level = table;
+	g_object_ref (table);
+	g_signal_connect (table, "destroy", G_CALLBACK (on_project_widget_destroy), dlg);
 
 	pos = 0;
 	name = g_file_get_parse_name (amp_project_get_file (project));
@@ -218,10 +216,10 @@ amp_configure_project_dialog (AmpProject *project, GError **error)
 	add_entry (project, NULL, _("Package name:"), AMP_PROPERTY_TARNAME, table, 4);
 	add_entry (project, NULL, _("URL:"), AMP_PROPERTY_URL, table, 5);*/
 	
-	gtk_widget_show_all (top_level);
+	gtk_widget_show_all (table);
 	g_object_unref (bxml);
 
-	return top_level;
+	return table;
 }
 
 GtkWidget *
diff --git a/plugins/am-project/am-project.ui b/plugins/am-project/am-project.ui
index 56aa7fe..353e6b1 100644
--- a/plugins/am-project/am-project.ui
+++ b/plugins/am-project/am-project.ui
@@ -105,317 +105,6 @@
       <action-widget response="-3">okbutton1</action-widget>
     </action-widgets>
   </object>
-  <object class="GtkNotebook" id="top_level">
-    <property name="visible">True</property>
-    <property name="can_focus">True</property>
-    <property name="border_width">6</property>
-    <child>
-      <object class="GtkTable" id="general_properties_table">
-        <property name="visible">True</property>
-        <property name="border_width">6</property>
-        <property name="n_rows">7</property>
-        <property name="n_columns">2</property>
-        <property name="column_spacing">12</property>
-        <property name="row_spacing">6</property>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-        <child>
-          <placeholder/>
-        </child>
-      </object>
-    </child>
-    <child type="tab">
-      <object class="GtkLabel" id="label1">
-        <property name="visible">True</property>
-        <property name="label" translatable="yes">General</property>
-      </object>
-      <packing>
-        <property name="tab_fill">False</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkVBox" id="vbox1">
-        <property name="height_request">300</property>
-        <property name="visible">True</property>
-        <property name="orientation">vertical</property>
-        <child>
-          <object class="GtkHButtonBox" id="hbuttonbox1">
-            <property name="visible">True</property>
-            <property name="border_width">5</property>
-            <property name="spacing">5</property>
-            <property name="layout_style">end</property>
-            <child>
-              <object class="GtkButton" id="add_module_button">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">True</property>
-                <child>
-                  <object class="GtkAlignment" id="alignment1">
-                    <property name="visible">True</property>
-                    <property name="xscale">0</property>
-                    <property name="yscale">0</property>
-                    <child>
-                      <object class="GtkHBox" id="hbox1">
-                        <property name="visible">True</property>
-                        <property name="spacing">2</property>
-                        <child>
-                          <object class="GtkImage" id="image1">
-                            <property name="visible">True</property>
-                            <property name="stock">gtk-add</property>
-                            <property name="icon-size">4</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="label3">
-                            <property name="visible">True</property>
-                            <property name="label" translatable="yes">Add _module</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>
-                    </child>
-                  </object>
-                </child>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="add_package_button">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">True</property>
-                <child>
-                  <object class="GtkAlignment" id="alignment2">
-                    <property name="visible">True</property>
-                    <property name="xscale">0</property>
-                    <property name="yscale">0</property>
-                    <child>
-                      <object class="GtkHBox" id="hbox2">
-                        <property name="visible">True</property>
-                        <property name="spacing">2</property>
-                        <child>
-                          <object class="GtkImage" id="image2">
-                            <property name="visible">True</property>
-                            <property name="stock">gtk-add</property>
-                            <property name="icon-size">4</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="label4">
-                            <property name="visible">True</property>
-                            <property name="label" translatable="yes">Add _Package</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>
-                    </child>
-                  </object>
-                </child>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="remove_button">
-                <property name="label">gtk-remove</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">2</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkScrolledWindow" id="scrolledwindow1">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="border_width">5</property>
-            <property name="hscrollbar_policy">automatic</property>
-            <property name="vscrollbar_policy">automatic</property>
-            <property name="shadow_type">etched-in</property>
-            <child>
-              <object class="GtkTreeView" id="packages_treeview">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="position">1</property>
-          </packing>
-        </child>
-      </object>
-      <packing>
-        <property name="position">1</property>
-      </packing>
-    </child>
-    <child type="tab">
-      <object class="GtkLabel" id="label2">
-        <property name="visible">True</property>
-        <property name="label" translatable="yes">Packages</property>
-      </object>
-      <packing>
-        <property name="position">1</property>
-        <property name="tab_fill">False</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkVBox" id="vbox3">
-        <property name="visible">True</property>
-        <property name="orientation">vertical</property>
-        <child>
-          <object class="GtkHButtonBox" id="hbuttonbox2">
-            <property name="visible">True</property>
-            <property name="spacing">5</property>
-            <property name="layout_style">end</property>
-            <child>
-              <object class="GtkButton" id="add_variable_button">
-                <property name="label">gtk-add</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">True</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="remove_variable_button">
-                <property name="label">gtk-remove</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_stock">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="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkScrolledWindow" id="scrolledwindow3">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="border_width">5</property>
-            <property name="hscrollbar_policy">automatic</property>
-            <property name="vscrollbar_policy">automatic</property>
-            <property name="shadow_type">in</property>
-            <child>
-              <object class="GtkTreeView" id="variables_treeview">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="position">1</property>
-          </packing>
-        </child>
-      </object>
-      <packing>
-        <property name="position">2</property>
-      </packing>
-    </child>
-    <child type="tab">
-      <object class="GtkLabel" id="label6">
-        <property name="visible">True</property>
-        <property name="label" translatable="yes">Variables</property>
-      </object>
-      <packing>
-        <property name="position">2</property>
-        <property name="tab_fill">False</property>
-      </packing>
-    </child>
-  </object>
   <object class="GtkDialog" id="properties_dialog">
     <property name="title" translatable="yes">Properties</property>
     <property name="modal">True</property>
@@ -669,4 +358,54 @@
       <placeholder/>
     </child>
   </object>
+  <object class="GtkTable" id="general_properties_table">
+    <property name="visible">True</property>
+    <property name="border_width">6</property>
+    <property name="n_rows">7</property>
+    <property name="n_columns">2</property>
+    <property name="column_spacing">12</property>
+    <property name="row_spacing">6</property>
+    <child>
+      <placeholder/>
+    </child>
+    <child>
+      <placeholder/>
+    </child>
+    <child>
+      <placeholder/>
+    </child>
+    <child>
+      <placeholder/>
+    </child>
+    <child>
+      <placeholder/>
+    </child>
+    <child>
+      <placeholder/>
+    </child>
+    <child>
+      <placeholder/>
+    </child>
+    <child>
+      <placeholder/>
+    </child>
+    <child>
+      <placeholder/>
+    </child>
+    <child>
+      <placeholder/>
+    </child>
+    <child>
+      <placeholder/>
+    </child>
+    <child>
+      <placeholder/>
+    </child>
+    <child>
+      <placeholder/>
+    </child>
+    <child>
+      <placeholder/>
+    </child>
+  </object>
 </interface>
diff --git a/plugins/project-manager/Makefile.am b/plugins/project-manager/Makefile.am
index e0da507..cdff830 100644
--- a/plugins/project-manager/Makefile.am
+++ b/plugins/project-manager/Makefile.am
@@ -45,7 +45,9 @@ libanjuta_project_manager_la_SOURCES = \
 	gbf-project-view.h	\
 	gbf-project-view.c	\
 	gbf-project-util.h	\
-	gbf-project-util.c
+	gbf-project-util.c	\
+	pkg-config.c		\
+	pkg-config.h
 
 libanjuta_project_manager_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
 
diff --git a/plugins/project-manager/anjuta-project-manager.xml b/plugins/project-manager/anjuta-project-manager.xml
index 87ab404..b831b1f 100644
--- a/plugins/project-manager/anjuta-project-manager.xml
+++ b/plugins/project-manager/anjuta-project-manager.xml
@@ -9,8 +9,10 @@
 	</menu>
 	<placeholder name="PlaceHolderProjectMenus">
 		<menu name="MenuProject" action="ActionMenuProject">
+				<menuitem name="AddPackage" action="ActionProjectAddPackage" />
 				<menuitem name="AddGroup" action="ActionProjectAddGroup" />
 				<menuitem name="AddTarget" action="ActionProjectAddTarget" />
+				<menuitem name="AddModule" action="ActionProjectAddModule" />
 				<menuitem name="AddSource" action="ActionProjectAddSource" />
 				<separator name="separator1"/>
 				<menuitem name="Properties" action="ActionProjectProperties"/>
@@ -21,8 +23,10 @@
 	<popup name="PopupProjectManager">
 		<placeholder name="PlaceholderPopupProjectOpen"/>
 		<placeholder name="PlaceholderPopupProjectBuild"/>
+		<menuitem name="AddPackage" action="ActionPopupProjectAddPackage"/>
 		<menuitem name="AddGroup" action="ActionPopupProjectAddGroup"/>
 		<menuitem name="AddTarget" action="ActionPopupProjectAddTarget"/>
+		<menuitem name="AddModule" action="ActionPopupProjectAddModule"/>
 		<menuitem name="AddSource" action="ActionPopupProjectAddSource"/>
 		<separator name="separator1"/>
 		<menuitem name="Remove" action="ActionPopupProjectRemove"/>
diff --git a/plugins/project-manager/create_dialogs.ui b/plugins/project-manager/create_dialogs.ui
index 13fe5c4..f00e266 100644
--- a/plugins/project-manager/create_dialogs.ui
+++ b/plugins/project-manager/create_dialogs.ui
@@ -1,6 +1,7 @@
 <?xml version="1.0"?>
-<!--*- mode: xml -*-->
 <interface>
+  <requires lib="gtk+" version="2.16"/>
+  <!-- interface-naming-policy project-wide -->
   <object class="GtkDialog" id="new_group_dialog">
     <property name="can_default">True</property>
     <property name="border_width">5</property>
@@ -8,7 +9,7 @@
     <property name="modal">True</property>
     <property name="default_width">400</property>
     <property name="default_height">450</property>
-    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+    <property name="type_hint">dialog</property>
     <property name="has_separator">False</property>
     <child internal-child="vbox">
       <object class="GtkVBox" id="dialog-vbox1">
@@ -33,15 +34,15 @@
                   <packing>
                     <property name="expand">False</property>
                     <property name="fill">False</property>
+                    <property name="position">0</property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkEntry" id="group_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 handler="on_group_name_entry_changed" name="changed"/>
+                    <signal name="changed" handler="on_group_name_entry_changed"/>
                   </object>
                   <packing>
                     <property name="position">1</property>
@@ -50,6 +51,7 @@
               </object>
               <packing>
                 <property name="expand">False</property>
+                <property name="position">0</property>
               </packing>
             </child>
             <child>
@@ -66,15 +68,16 @@
                   <packing>
                     <property name="expand">False</property>
                     <property name="fill">False</property>
+                    <property name="position">0</property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkScrolledWindow" id="groups_ph">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
-                    <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
-                    <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
-                    <property name="shadow_type">GTK_SHADOW_IN</property>
+                    <property name="hscrollbar_policy">automatic</property>
+                    <property name="vscrollbar_policy">automatic</property>
+                    <property name="shadow_type">in</property>
                     <child>
                       <object class="GbfProjectView" id="groups_view">
                         <property name="visible">True</property>
@@ -99,33 +102,43 @@
           <object class="GtkHButtonBox" id="dialog-action_area1">
             <property name="visible">True</property>
             <property name="can_default">True</property>
-            <property name="layout_style">GTK_BUTTONBOX_END</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="label">gtk-cancel</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="ok_group_button">
+                <property name="label">gtk-add</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="has_default">True</property>
-                <property name="label">gtk-add</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">1</property>
               </packing>
             </child>
           </object>
           <packing>
             <property name="expand">False</property>
-            <property name="pack_type">GTK_PACK_END</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
           </packing>
         </child>
       </object>
@@ -141,7 +154,7 @@
     <property name="modal">True</property>
     <property name="default_width">400</property>
     <property name="default_height">450</property>
-    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+    <property name="type_hint">dialog</property>
     <property name="has_separator">False</property>
     <child internal-child="vbox">
       <object class="GtkVBox" id="vbox3">
@@ -163,8 +176,8 @@
                   <object class="GtkComboBox" id="target_type_combo">
                     <property name="visible">True</property>
                     <child internal-child="accessible">
-                      <object class="AtkObject" id="a11y-target_type_combo1">
-                        <property name="AtkObject::accessible_name" translatable="yes">TargetTypes</property>
+                      <object class="AtkObject" id="dummy">
+                        <property name="AtkObject::accessible-name" translatable="yes">TargetTypes</property>
                       </object>
                     </child>
                   </object>
@@ -188,20 +201,19 @@
                     <property name="top_attach">1</property>
                     <property name="bottom_attach">2</property>
                     <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"/>
+                    <property name="y_options"></property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkEntry" id="target_name_entry">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
-                    <property name="invisible_char">*</property>
                     <property name="activates_default">True</property>
                   </object>
                   <packing>
                     <property name="left_attach">1</property>
                     <property name="right_attach">2</property>
-                    <property name="y_options"/>
+                    <property name="y_options"></property>
                   </packing>
                 </child>
                 <child>
@@ -214,12 +226,13 @@
                   </object>
                   <packing>
                     <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"/>
+                    <property name="y_options"></property>
                   </packing>
                 </child>
               </object>
               <packing>
                 <property name="expand">False</property>
+                <property name="position">0</property>
               </packing>
             </child>
             <child>
@@ -236,15 +249,16 @@
                   <packing>
                     <property name="expand">False</property>
                     <property name="fill">False</property>
+                    <property name="position">0</property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkScrolledWindow" id="target_groups_ph">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
-                    <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
-                    <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
-                    <property name="shadow_type">GTK_SHADOW_IN</property>
+                    <property name="hscrollbar_policy">automatic</property>
+                    <property name="vscrollbar_policy">automatic</property>
+                    <property name="shadow_type">in</property>
                     <child>
                       <object class="GbfProjectView" id="target_groups_view">
                         <property name="visible">True</property>
@@ -268,33 +282,43 @@
         <child internal-child="action_area">
           <object class="GtkHButtonBox" id="hbuttonbox1">
             <property name="visible">True</property>
-            <property name="layout_style">GTK_BUTTONBOX_END</property>
+            <property name="layout_style">end</property>
             <child>
               <object class="GtkButton" id="button2">
+                <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="label">gtk-cancel</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="ok_target_button">
+                <property name="label">gtk-add</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="has_default">True</property>
-                <property name="label">gtk-add</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">1</property>
               </packing>
             </child>
           </object>
           <packing>
             <property name="expand">False</property>
-            <property name="pack_type">GTK_PACK_END</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
           </packing>
         </child>
       </object>
@@ -312,7 +336,7 @@
     <property name="default_width">400</property>
     <property name="default_height">550</property>
     <property name="destroy_with_parent">True</property>
-    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+    <property name="type_hint">dialog</property>
     <property name="has_separator">False</property>
     <child internal-child="vbox">
       <object class="GtkVBox" id="vbox6">
@@ -337,15 +361,16 @@
                   <packing>
                     <property name="expand">False</property>
                     <property name="fill">False</property>
+                    <property name="position">0</property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkScrolledWindow" id="targets_ph">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
-                    <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
-                    <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
-                    <property name="shadow_type">GTK_SHADOW_IN</property>
+                    <property name="hscrollbar_policy">automatic</property>
+                    <property name="vscrollbar_policy">automatic</property>
+                    <property name="shadow_type">in</property>
                     <child>
                       <object class="GbfProjectView" id="targets_view">
                         <property name="visible">True</property>
@@ -357,6 +382,9 @@
                   </packing>
                 </child>
               </object>
+              <packing>
+                <property name="position">0</property>
+              </packing>
             </child>
             <child>
               <object class="GtkTable" id="table2">
@@ -367,9 +395,9 @@
                   <object class="GtkScrolledWindow" id="scrolledwindow1">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
-                    <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
-                    <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
-                    <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
+                    <property name="hscrollbar_policy">automatic</property>
+                    <property name="vscrollbar_policy">automatic</property>
+                    <property name="shadow_type">etched-in</property>
                     <child>
                       <object class="GtkTreeView" id="source_file_tree">
                         <property name="visible">True</property>
@@ -389,16 +417,17 @@
                 </child>
                 <child>
                   <object class="GtkButton" id="browse_button">
+                    <property name="label" translatable="yes">_Select file to add&#x2026;</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
-                    <property name="label" translatable="yes">_Select file to addâ?¦</property>
+                    <property name="receives_default">False</property>
                     <property name="use_underline">True</property>
                   </object>
                   <packing>
                     <property name="left_attach">1</property>
                     <property name="right_attach">2</property>
-                    <property name="x_options"/>
-                    <property name="y_options"/>
+                    <property name="x_options"></property>
+                    <property name="y_options"></property>
                     <property name="x_padding">5</property>
                     <property name="y_padding">2</property>
                   </packing>
@@ -410,7 +439,7 @@
                     <property name="label" translatable="yes">Source files:</property>
                   </object>
                   <packing>
-                    <property name="y_options"/>
+                    <property name="y_options"></property>
                     <property name="x_padding">5</property>
                     <property name="y_padding">2</property>
                   </packing>
@@ -429,33 +458,43 @@
         <child internal-child="action_area">
           <object class="GtkHButtonBox" id="hbuttonbox2">
             <property name="visible">True</property>
-            <property name="layout_style">GTK_BUTTONBOX_END</property>
+            <property name="layout_style">end</property>
             <child>
               <object class="GtkButton" id="button4">
+                <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="label">gtk-cancel</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="ok_source_button">
+                <property name="label">gtk-add</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="has_default">True</property>
-                <property name="label">gtk-add</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">1</property>
               </packing>
             </child>
           </object>
           <packing>
             <property name="expand">False</property>
-            <property name="pack_type">GTK_PACK_END</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
           </packing>
         </child>
       </object>
@@ -465,4 +504,327 @@
       <action-widget response="-5">ok_source_button</action-widget>
     </action-widgets>
   </object>
+  <object class="GtkDialog" id="add_module_dialog">
+    <property name="can_default">True</property>
+    <property name="border_width">5</property>
+    <property name="title" translatable="yes">Add Module</property>
+    <property name="modal">True</property>
+    <property name="default_width">400</property>
+    <property name="default_height">550</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="dialog-vbox5">
+        <property name="visible">True</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child>
+          <object class="GtkVBox" id="vbox10">
+            <property name="visible">True</property>
+            <property name="border_width">5</property>
+            <property name="orientation">vertical</property>
+            <property name="spacing">12</property>
+            <child>
+              <object class="GtkVBox" id="vbox9">
+                <property name="visible">True</property>
+                <property name="orientation">vertical</property>
+                <property name="spacing">6</property>
+                <child>
+                  <object class="GtkLabel" id="label6">
+                    <property name="visible">True</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">Select the _target for the module:</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="GtkScrolledWindow" id="targets_ph1">
+                    <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="GbfProjectView" id="module_targets_view">
+                        <property name="visible">True</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkTable" id="table3">
+                <property name="visible">True</property>
+                <property name="n_rows">2</property>
+                <property name="n_columns">2</property>
+                <child>
+                  <object class="GtkScrolledWindow" id="modules_ph">
+                    <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="GbfProjectView" id="modules_view">
+                        <property name="visible">True</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
+                    <property name="x_padding">5</property>
+                    <property name="y_padding">5</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkButton" id="new_package_button">
+                    <property name="label" translatable="yes">_Add new package&#x2026;</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="use_underline">True</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="x_options"></property>
+                    <property name="y_options"></property>
+                    <property name="x_padding">5</property>
+                    <property name="y_padding">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="label7">
+                    <property name="visible">True</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">Modules:</property>
+                  </object>
+                  <packing>
+                    <property name="y_options"></property>
+                    <property name="x_padding">5</property>
+                    <property name="y_padding">2</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <object class="GtkHButtonBox" id="dialog-action_area5">
+            <property name="visible">True</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="button1">
+                <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">True</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="ok_module_button">
+                <property name="label">gtk-add</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="has_default">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">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="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-6">button1</action-widget>
+      <action-widget response="-5">ok_module_button</action-widget>
+    </action-widgets>
+  </object>
+  <object class="GtkDialog" id="add_package_dialog">
+    <property name="can_default">True</property>
+    <property name="border_width">5</property>
+    <property name="title" translatable="yes">Add Package</property>
+    <property name="modal">True</property>
+    <property name="default_width">400</property>
+    <property name="default_height">550</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="dialog-vbox7">
+        <property name="visible">True</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child>
+          <object class="GtkVBox" id="vbox11">
+            <property name="visible">True</property>
+            <property name="border_width">5</property>
+            <property name="orientation">vertical</property>
+            <property name="spacing">12</property>
+            <child>
+              <object class="GtkHBox" id="hbox2">
+                <property name="visible">True</property>
+                <property name="spacing">6</property>
+                <child>
+                  <object class="GtkLabel" id="label11">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">_Module name:</property>
+                    <property name="use_underline">True</property>
+                    <property name="mnemonic_widget">group_name_entry</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkComboBoxEntry" id="module_entry">
+                    <property name="visible">True</property>
+                  </object>
+                  <packing>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkVBox" id="vbox12">
+                <property name="visible">True</property>
+                <property name="orientation">vertical</property>
+                <property name="spacing">6</property>
+                <child>
+                  <object class="GtkLabel" id="label10">
+                    <property name="visible">True</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">Package list:</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="GtkScrolledWindow" id="scrolledwindow2">
+                    <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="packages_view">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <object class="GtkHButtonBox" id="dialog-action_area7">
+            <property name="visible">True</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="button3">
+                <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">True</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="ok_package_button">
+                <property name="label">gtk-add</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="has_default">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">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="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-6">button3</action-widget>
+      <action-widget response="-5">ok_package_button</action-widget>
+    </action-widgets>
+  </object>
 </interface>
diff --git a/plugins/project-manager/gbf-project-model.c b/plugins/project-manager/gbf-project-model.c
index 3cff8ea..8b68585 100644
--- a/plugins/project-manager/gbf-project-model.c
+++ b/plugins/project-manager/gbf-project-model.c
@@ -517,7 +517,7 @@ add_module (GbfProjectModel 		*model,
 	if ((!module) || (anjuta_project_node_get_type (module) != ANJUTA_PROJECT_MODULE))
 		return;
 	
-	data = gbf_tree_data_new_package (module);
+	data = gbf_tree_data_new_module (module);
 	gtk_tree_store_append (GTK_TREE_STORE (model), &iter, parent);
 	gtk_tree_store_set (GTK_TREE_STORE (model), &iter, 
 			    GBF_PROJECT_MODEL_COLUMN_DATA, data,
diff --git a/plugins/project-manager/gbf-project-util.c b/plugins/project-manager/gbf-project-util.c
index c54f8e6..21b69a7 100644
--- a/plugins/project-manager/gbf-project-util.c
+++ b/plugins/project-manager/gbf-project-util.c
@@ -34,6 +34,7 @@
 #include "gbf-project-view.h"
 #include "gbf-project-model.h"
 #include "gbf-project-util.h"
+#include "pkg-config.h"
 
 #define ICON_SIZE 16
 
@@ -485,6 +486,62 @@ setup_targets_treeview (GbfProjectModel     *model,
     }
 }
 
+static gboolean
+modules_filter_fn (GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
+{
+    GbfTreeData *data = NULL;
+    gboolean retval = FALSE;
+    GtkTreeIter root;
+
+    gtk_tree_model_get (model, iter,
+                        GBF_PROJECT_MODEL_COLUMN_DATA, &data, -1);
+    retval = (data && !data->is_shortcut &&
+              (!gtk_tree_model_iter_parent (model, &root, iter) ||
+               data->type == GBF_TREE_NODE_MODULE ||
+               data->type == GBF_TREE_NODE_PACKAGE));
+    
+    return retval;
+}
+
+static void 
+setup_modules_treeview (GbfProjectModel     *model,
+                        GtkWidget           *view,
+                        GtkTreeIter         *select_module)
+{
+    GtkTreeModel *filter;
+    GtkTreeIter iter_filter;
+    GtkTreePath *path = NULL;
+    
+    g_return_if_fail (model != NULL);
+    g_return_if_fail (view != NULL && GBF_IS_PROJECT_VIEW (view));
+
+    filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (model), NULL);
+    gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (filter),
+                                            modules_filter_fn, NULL, NULL);
+    gtk_tree_view_set_model (GTK_TREE_VIEW (view), GTK_TREE_MODEL (filter));
+    g_object_unref (filter);
+
+    /* select default module */
+    if (select_module) {
+        if (gtk_tree_model_filter_convert_child_iter_to_iter (
+                GTK_TREE_MODEL_FILTER (filter), &iter_filter, select_module))
+        {
+            path = gtk_tree_model_get_path (filter, &iter_filter);
+        }
+    }
+    if (path)
+    {
+        gtk_tree_view_expand_to_path (GTK_TREE_VIEW (view), path);
+        gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), path, NULL, FALSE);
+        gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (view), path, NULL,
+                                      TRUE, 0.5, 0.0);
+    } else {
+        path = gtk_tree_path_new_first ();
+        gtk_tree_view_expand_to_path (GTK_TREE_VIEW (view), path);
+    }
+    gtk_tree_path_free (path);
+}
+
 static void
 browse_button_clicked_cb (GtkWidget *widget, gpointer user_data)
 {
@@ -633,7 +690,7 @@ gbf_project_util_add_source_multi (GbfProjectModel     *model,
     source_file_tree = GTK_WIDGET (gtk_builder_get_object (gui, "source_file_tree"));
     browse_button = GTK_WIDGET (gtk_builder_get_object (gui, "browse_button"));
     ok_button = GTK_WIDGET (gtk_builder_get_object (gui, "ok_source_button"));
-    
+
     /* Prepare file tree */
     list = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING);
     gtk_tree_view_set_model (GTK_TREE_VIEW (source_file_tree),
@@ -825,3 +882,429 @@ gbf_project_util_replace_by_file (GList* list)
 
         return list;
 }
+
+static void
+new_package_button_clicked_cb (GtkWidget *widget, gpointer user_data)
+{
+}
+
+static void
+on_cursor_changed(GtkTreeView* view, gpointer data)
+{
+    GtkWidget* button = GTK_WIDGET(data);
+    GtkTreeSelection *selection = gtk_tree_view_get_selection(view);
+
+    if (gtk_tree_selection_count_selected_rows (selection) > 0)
+        gtk_widget_set_sensitive(button, TRUE);
+    else
+        gtk_widget_set_sensitive(button, FALSE);
+}
+
+GList*
+gbf_project_util_add_module (GbfProjectModel   *model,
+                             GtkWindow          *parent,
+                             GtkTreeIter        *default_target,
+                             const gchar        *default_module)
+{
+    GtkBuilder *gui;
+    GtkWidget *dialog;
+    GtkWidget *ok_button, *new_button;
+    GtkWidget *targets_view;
+    GtkWidget *modules_view;
+    gint response;
+    IAnjutaProject *project;
+    gboolean finished = FALSE;
+    GList* new_modules = NULL;
+    GtkTreeSelection *module_selection;
+    
+    g_return_val_if_fail (model != NULL, NULL);
+    
+    project = gbf_project_model_get_project (model);
+    if (!project)
+        return NULL;
+
+    gui = load_interface ("add_module_dialog");
+    g_return_val_if_fail (gui != NULL, NULL);
+    
+    /* get all needed widgets */
+    dialog = GTK_WIDGET (gtk_builder_get_object (gui, "add_module_dialog"));
+    targets_view = GTK_WIDGET (gtk_builder_get_object (gui, "module_targets_view"));
+    modules_view = GTK_WIDGET (gtk_builder_get_object (gui, "modules_view"));
+    new_button = GTK_WIDGET (gtk_builder_get_object (gui, "new_package_button"));
+    ok_button = GTK_WIDGET (gtk_builder_get_object (gui, "ok_module_button"));
+
+
+    g_signal_connect (new_button, "clicked",
+                      G_CALLBACK (new_package_button_clicked_cb),modules_view);
+    
+    setup_targets_treeview (model, targets_view, default_target);
+    gtk_widget_show (targets_view);
+    setup_modules_treeview (model, modules_view, NULL);
+    gtk_widget_show (modules_view);
+    module_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (modules_view));
+    gtk_tree_selection_set_mode (module_selection, GTK_SELECTION_MULTIPLE);
+
+    if (gbf_project_view_find_selected (GBF_PROJECT_VIEW (modules_view), ANJUTA_PROJECT_MODULE))
+    {
+        gtk_widget_set_sensitive (ok_button, TRUE);
+    }
+    else
+    {
+        gtk_widget_set_sensitive (ok_button, FALSE);
+    }
+    g_signal_connect (G_OBJECT(modules_view), "cursor-changed",
+        G_CALLBACK(on_cursor_changed), ok_button);
+
+    
+    if (parent) {
+        gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
+    }
+
+    if (default_module)
+        gtk_widget_grab_focus (modules_view);
+    else
+        gtk_widget_grab_focus (targets_view);
+    
+    /* execute dialog */
+    while (!finished) {
+        response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+        switch (response) {
+            case GTK_RESPONSE_OK: 
+            {
+                AnjutaProjectNode *target;
+            
+                target = gbf_project_view_find_selected (GBF_PROJECT_VIEW (targets_view),
+                                                         ANJUTA_PROJECT_TARGET);
+                if (target) {
+                    GString *err_mesg = g_string_new (NULL);
+                    GList *list;
+                    GList *node;
+                    
+                    list = gbf_project_view_get_all_selected (GBF_PROJECT_VIEW (modules_view));
+                    for (node = g_list_first (list); node != NULL; node = g_list_next (node))
+                    {
+                        GError *err = NULL;
+                        AnjutaProjectNode* selected_module = (AnjutaProjectNode *)node->data;
+                        AnjutaProjectNode* new_module;
+                        gchar* uri = NULL;
+                        GFile* module_file;
+
+                        /*module_file = gbf_tree_data_get_file (selected_module);
+                        new_module = ianjuta_project_add_module (project,
+                                                            target,
+                                                            module_file,
+                                                            &err);
+                        g_object_unref (module_file);*/
+                        new_module = NULL;
+                        if (err) {
+                            gchar *str = g_strdup_printf ("%s: %s\n",
+                                                            uri,
+                                                            err->message);
+                            g_string_append (err_mesg, str);
+                            g_error_free (err);
+                            g_free (str);
+                        }
+                        else
+                            new_modules = g_list_append (new_modules,
+                                                        new_module);
+
+                        g_free (uri);
+                    }
+                    g_list_free (list);
+                    
+                    if (err_mesg->str && strlen (err_mesg->str) > 0) {
+                        error_dialog (parent, _("Cannot add modules"),
+                                        "%s", err_mesg->str);
+                    } else {
+                        finished = TRUE;
+                    }
+                    g_string_free (err_mesg, TRUE);
+                } else {
+                    error_dialog (parent, _("Cannot add modules"),
+                            "%s", _("No target has been selected"));
+                }
+                
+                break;
+            }
+            default:
+                finished = TRUE;
+                break;
+        }
+    }
+    
+    /* destroy stuff */
+    gtk_widget_destroy (dialog);
+    g_object_unref (gui);
+    
+    return new_modules;
+}
+
+static void on_changed_disconnect (GtkEditable* entry, gpointer data);
+
+static void
+on_cursor_changed_set_entry(GtkTreeView* view, gpointer data)
+{
+    GtkWidget* entry = GTK_WIDGET(data);
+    GtkTreeSelection *selection = gtk_tree_view_get_selection(view);
+
+    if (gtk_tree_selection_count_selected_rows (selection) == 1)
+    {
+        GtkTreeModel *model;
+        GList *list;
+        GtkTreeIter iter;
+
+        list = gtk_tree_selection_get_selected_rows (selection, &model);
+        if (gtk_tree_model_get_iter (model, &iter, (GtkTreePath *)(list->data)))
+        {
+            gchar *name;
+            gchar *ptr;
+            
+            gtk_tree_model_get (model, &iter, COL_PKG_PACKAGE, &name, -1);
+
+            /* Remove numeric suffix */
+            ptr = name + strlen(name) - 1;
+            while (g_ascii_isdigit (*ptr))
+            {
+                while (g_ascii_isdigit (*ptr)) ptr--;
+                if ((*ptr != '_') && (*ptr != '-') && (*ptr != '.')) break;
+                *ptr = '\0';
+                ptr--;
+            }
+
+            /* Convert to upper case and remove invalid characters */
+            for (ptr = name; *ptr != '\0'; ptr++)
+            {
+                if (g_ascii_isalnum (*ptr))
+                {
+                    *ptr = g_ascii_toupper (*ptr);
+                }
+                else
+                {
+                    *ptr = '_';
+                }
+            }
+
+            g_signal_handlers_block_by_func (G_OBJECT (entry), on_changed_disconnect, view);
+            gtk_entry_set_text (GTK_ENTRY (entry), name);
+            g_signal_handlers_unblock_by_func (G_OBJECT (entry), on_changed_disconnect, view);
+            g_free (name);
+        }
+        
+        g_list_foreach (list, (GFunc)gtk_tree_path_free, NULL);
+        g_list_free (list);
+    }
+}
+
+static void
+on_changed_disconnect (GtkEditable* entry, gpointer data)
+{
+    g_signal_handlers_block_by_func (G_OBJECT (data), on_cursor_changed_set_entry, entry);
+}
+
+AnjutaProjectNode* 
+gbf_project_util_add_package (GbfProjectModel   *model,
+                              GtkWindow        *parent,
+                              GtkTreeIter      *default_module,
+                              GList            *packages_to_add)
+{
+    GtkBuilder *gui;
+    GtkWidget *dialog;
+    GtkWidget *ok_button;
+    GtkWidget *module_entry;
+    GtkWidget *packages_view;
+    GtkCellRenderer* renderer;
+    GtkListStore *store;
+    GList *modules;
+    GList *node;
+    GtkTreeViewColumn *col;
+    gint response;
+    IAnjutaProject *project;
+    gboolean finished = FALSE;
+    AnjutaProjectNode* module = NULL;
+    GtkTreeSelection *package_selection;
+    GtkTreeIter root;
+    gboolean valid;
+    gint default_pos = -1;
+    
+    g_return_val_if_fail (model != NULL, NULL);
+    
+    project = gbf_project_model_get_project (model);
+    if (!project)
+        return NULL;
+
+    gui = load_interface ("add_package_dialog");
+    g_return_val_if_fail (gui != NULL, NULL);
+    
+    /* get all needed widgets */
+    dialog = GTK_WIDGET (gtk_builder_get_object (gui, "add_package_dialog"));
+    module_entry = GTK_WIDGET (gtk_builder_get_object (gui, "module_entry"));
+    packages_view = GTK_WIDGET (gtk_builder_get_object (gui, "packages_view"));
+    ok_button = GTK_WIDGET (gtk_builder_get_object (gui, "ok_package_button"));
+
+    /* Fill combo box with modules */
+    store = gtk_list_store_new(1, G_TYPE_STRING);
+    gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (module_entry), 0);
+
+    for (valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &root); valid != FALSE; valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &root))
+    {
+        GbfTreeData *data;
+        
+        gtk_tree_model_get (GTK_TREE_MODEL (model), &root, GBF_PROJECT_MODEL_COLUMN_DATA, &data, -1);
+        if (data && (data->type == GBF_TREE_NODE_GROUP)) break;
+    }
+    
+    if (valid)
+    {
+        GtkTreeIter iter;
+        gint pos = 0;
+        GbfTreeData *data;
+        GtkTreePath *default_path = gtk_tree_model_get_path(GTK_TREE_MODEL (model), default_module);
+
+        gtk_tree_model_get (GTK_TREE_MODEL (model), &root, GBF_PROJECT_MODEL_COLUMN_DATA, &data, -1);
+        
+        for (valid = gtk_tree_model_iter_children (GTK_TREE_MODEL (model), &iter, &root); valid != FALSE; valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &iter))
+        {
+            GbfTreeData *data;
+            
+            gtk_tree_model_get (GTK_TREE_MODEL (model), &iter, GBF_PROJECT_MODEL_COLUMN_DATA, &data, -1);
+
+            g_message ("module %p name %s type %d module %d", data, data != NULL ? data->name : "(null)", data != NULL ? data->type : -1, GBF_TREE_NODE_MODULE);
+            if (data && (data->type == GBF_TREE_NODE_MODULE))
+            {
+                GtkTreeIter list_iter;
+                GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL (model), &iter);
+
+                g_message ("append name %s", data->name);
+                gtk_list_store_append (store, &list_iter);
+                gtk_list_store_set (store, &list_iter, 0, data->name, -1);
+                if (gtk_tree_path_compare (path, default_path) == 0)
+                {
+                    default_pos = pos;
+                }
+                gtk_tree_path_free (path);
+                pos++;
+            }
+        }
+        gtk_tree_path_free (default_path);
+    }
+    gtk_combo_box_set_model (GTK_COMBO_BOX(module_entry), GTK_TREE_MODEL(store));
+    gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (module_entry), 0);
+//    g_object_unref (store);
+    if (default_pos >= 0)
+    {
+        gtk_combo_box_set_active (GTK_COMBO_BOX (module_entry), default_pos);
+    }
+    else
+    {
+        /* Create automatically a module name from the package name when missing */
+        GtkWidget *entry = gtk_bin_get_child (GTK_BIN (module_entry));
+        
+        g_signal_connect (G_OBJECT(packages_view), "cursor-changed",
+            G_CALLBACK(on_cursor_changed_set_entry), entry);
+        g_signal_connect (G_OBJECT(entry), "changed",
+            G_CALLBACK(on_changed_disconnect), packages_view);
+    }
+    
+    /* Fill package list */
+    renderer = gtk_cell_renderer_text_new ();
+    col = gtk_tree_view_column_new_with_attributes (_("Package"),
+                                                    renderer,
+                                                    "text", COL_PKG_PACKAGE,
+                                                    NULL);
+    gtk_tree_view_column_set_sort_column_id (col, COL_PKG_PACKAGE);
+    gtk_tree_view_append_column (GTK_TREE_VIEW (packages_view), col);
+    renderer = gtk_cell_renderer_text_new ();
+    col = gtk_tree_view_column_new_with_attributes (_("Description"),
+                                                    renderer,
+                                                    "text",
+                                                    COL_PKG_DESCRIPTION,
+                                                    NULL);
+    gtk_tree_view_append_column (GTK_TREE_VIEW (packages_view), col);
+    store = packages_get_pkgconfig_list ();
+    gtk_tree_view_set_model (GTK_TREE_VIEW (packages_view),
+                            GTK_TREE_MODEL (store));
+
+    on_cursor_changed (GTK_TREE_VIEW (packages_view), ok_button);
+    g_signal_connect (G_OBJECT(packages_view), "cursor-changed",
+        G_CALLBACK(on_cursor_changed), ok_button);
+
+    if (parent) {
+        gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
+    }
+    
+    /* execute dialog */
+    while (!finished) {
+        response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+        switch (response) {
+            case GTK_RESPONSE_OK: 
+            {
+                AnjutaProjectNode *target;
+
+#if 0
+                target = gbf_project_view_find_selected (GBF_PROJECT_VIEW (targets_view),
+                                                         ANJUTA_PROJECT_TARGET);
+                if (target) {
+                    GString *err_mesg = g_string_new (NULL);
+                    GList *list;
+                    GList *node;
+                    
+                    list = gbf_project_view_get_all_selected (GBF_PROJECT_VIEW (modules_view));
+                    for (node = g_list_first (list); node != NULL; node = g_list_next (node))
+                    {
+                        GError *err = NULL;
+                        AnjutaProjectNode* selected_module = (AnjutaProjectNode *)node->data;
+                        AnjutaProjectNode* new_module;
+                        gchar* uri = NULL;
+                        GFile* module_file;
+
+                        /*module_file = gbf_tree_data_get_file (selected_module);
+                        new_module = ianjuta_project_add_module (project,
+                                                            target,
+                                                            module_file,
+                                                            &err);
+                        g_object_unref (module_file);*/
+                        new_module = NULL;
+                        if (err) {
+                            gchar *str = g_strdup_printf ("%s: %s\n",
+                                                            uri,
+                                                            err->message);
+                            g_string_append (err_mesg, str);
+                            g_error_free (err);
+                            g_free (str);
+                        }
+                        else
+                            new_modules = g_list_append (new_modules,
+                                                        new_module);
+
+                        g_free (uri);
+                    }
+                    g_list_free (list);
+                    
+                    if (err_mesg->str && strlen (err_mesg->str) > 0) {
+                        error_dialog (parent, _("Cannot add packages"),
+                                        "%s", err_mesg->str);
+                    } else {
+                        finished = TRUE;
+                    }
+                    g_string_free (err_mesg, TRUE);
+                } else {
+                    error_dialog (parent, _("Cannot add packages"),
+                            "%s", _("No target has been selected"));
+                }
+#endif
+                break;
+            }
+            default:
+                finished = TRUE;
+                break;
+        }
+    }
+    
+    /* destroy stuff */
+    gtk_widget_destroy (dialog);
+    g_object_unref (gui);
+    
+    return module;
+}
diff --git a/plugins/project-manager/gbf-project-util.h b/plugins/project-manager/gbf-project-util.h
index 9b864ba..18d928b 100644
--- a/plugins/project-manager/gbf-project-util.h
+++ b/plugins/project-manager/gbf-project-util.h
@@ -45,6 +45,17 @@ AnjutaProjectNode* gbf_project_util_add_source (GbfProjectModel   *model,
 				                GtkTreeIter         *default_target,
 				                const gchar         *default_uri_to_add);
 
+GList* gbf_project_util_add_module             (GbfProjectModel   *model,
+				                GtkWindow          *parent,
+				                GtkTreeIter        *default_target,
+				                const gchar        *default_module_name_to_add);
+
+AnjutaProjectNode* gbf_project_util_add_package(GbfProjectModel   *model,
+				                GtkWindow          *parent,
+				                GtkTreeIter        *default_module,
+				                GList              *packages_to_add);
+
+
 GList* gbf_project_util_add_source_multi (GbfProjectModel   *model,
 				        GtkWindow           *parent,
         		                GtkTreeIter         *default_target,
diff --git a/plugins/project-manager/gbf-project-view.c b/plugins/project-manager/gbf-project-view.c
index 9a712ce..b9f78e3 100644
--- a/plugins/project-manager/gbf-project-view.c
+++ b/plugins/project-manager/gbf-project-view.c
@@ -201,6 +201,24 @@ set_pixbuf (GtkTreeViewColumn *tree_column,
 							   NULL);
 			break;
 		}
+		case GBF_TREE_NODE_MODULE: 
+		{
+			pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default(),
+							   GTK_STOCK_DND_MULTIPLE,
+							   ICON_SIZE,
+							   GTK_ICON_LOOKUP_GENERIC_FALLBACK,
+							   NULL);
+			break;
+		}
+		case GBF_TREE_NODE_PACKAGE: 
+		{
+			pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default(),
+							   GTK_STOCK_DND,
+							   ICON_SIZE,
+							   GTK_ICON_LOOKUP_GENERIC_FALLBACK,
+							   NULL);
+			break;
+		}
 		default:
 			pixbuf = NULL;
 	}
diff --git a/plugins/project-manager/gbf-tree-data.c b/plugins/project-manager/gbf-tree-data.c
index 784985f..d8483b1 100644
--- a/plugins/project-manager/gbf-tree-data.c
+++ b/plugins/project-manager/gbf-tree-data.c
@@ -150,6 +150,12 @@ gbf_tree_data_get_path (GbfTreeData *data)
 	return path;
 }
 
+const gchar *
+gbf_tree_data_get_name (GbfTreeData *data)
+{
+	return data->name;
+}
+
 gboolean
 gbf_tree_data_equal (GbfTreeData *data_a, GbfTreeData *data_b)
 {
diff --git a/plugins/project-manager/gbf-tree-data.h b/plugins/project-manager/gbf-tree-data.h
index 0bd5d64..a1d0a03 100644
--- a/plugins/project-manager/gbf-tree-data.h
+++ b/plugins/project-manager/gbf-tree-data.h
@@ -59,6 +59,7 @@ AnjutaProjectNode *gbf_tree_data_get_node	    (GbfTreeData		 *data,
 
 gchar	      *gbf_tree_data_get_uri		    (GbfTreeData          *data);
 GFile	      *gbf_tree_data_get_file		    (GbfTreeData          *data);
+const gchar   *gdb_tree_data_get_name		    (GbfTreeData          *data);
 
 gchar		  *gbf_tree_data_get_path		    (GbfTreeData          *data);
 
diff --git a/plugins/project-manager/plugin.c b/plugins/project-manager/plugin.c
index e682696..fbc48ed 100644
--- a/plugins/project-manager/plugin.c
+++ b/plugins/project-manager/plugin.c
@@ -558,6 +558,37 @@ on_add_group (GtkAction *action, ProjectManagerPlugin *plugin)
 }
 
 static void
+on_add_package (GtkAction *action, ProjectManagerPlugin *plugin)
+{
+	GtkTreeIter selected_module;
+	AnjutaProjectNode *new_module;
+	
+	update_operation_begin (plugin);
+	gbf_project_view_get_first_selected (GBF_PROJECT_VIEW (plugin->view), &selected_module);
+	
+	new_module = gbf_project_util_add_package (plugin->model,
+										   get_plugin_parent_window (plugin),
+										   &selected_module, NULL);
+	update_operation_end (plugin, TRUE);
+}
+
+static void
+on_add_module (GtkAction *action, ProjectManagerPlugin *plugin)
+{
+	GtkTreeIter selected_target;
+	GList *new_modules;
+	
+	update_operation_begin (plugin);
+	gbf_project_view_get_first_selected (GBF_PROJECT_VIEW (plugin->view), &selected_target);
+	
+	new_modules = gbf_project_util_add_module (plugin->model,
+										   get_plugin_parent_window (plugin),
+										   &selected_target, NULL);
+	g_list_free (new_modules);
+	update_operation_end (plugin, TRUE);
+}
+
+static void
 on_add_target (GtkAction *action, ProjectManagerPlugin *plugin)
 {
 	GFile *target;
@@ -622,6 +653,37 @@ on_popup_properties (GtkAction *action, ProjectManagerPlugin *plugin)
 }
 
 static void
+on_popup_add_package (GtkAction *action, ProjectManagerPlugin *plugin)
+{
+	GtkTreeIter selected_module;
+	AnjutaProjectNode *module;
+	
+	update_operation_begin (plugin);
+	gbf_project_view_get_first_selected (GBF_PROJECT_VIEW (plugin->view), &selected_module);
+	
+	module = gbf_project_util_add_package (plugin->model,
+										   get_plugin_parent_window (plugin),
+										   &selected_module, NULL);
+	update_operation_end (plugin, TRUE);
+}
+
+static void
+on_popup_add_module (GtkAction *action, ProjectManagerPlugin *plugin)
+{
+	GtkTreeIter selected_target;
+	GList *new_modules;
+	
+	update_operation_begin (plugin);
+	gbf_project_view_get_first_selected (GBF_PROJECT_VIEW (plugin->view), &selected_target);
+	
+	new_modules = gbf_project_util_add_module (plugin->model,
+										   get_plugin_parent_window (plugin),
+										   &selected_target, NULL);
+	g_list_free (new_modules);
+	update_operation_end (plugin, TRUE);
+}
+
+static void
 on_popup_add_group (GtkAction *action, ProjectManagerPlugin *plugin)
 {
 	GtkTreeIter selected_group;
@@ -913,6 +975,16 @@ static GtkActionEntry pm_actions[] =
 		G_CALLBACK (on_refresh)
 	},
 	{
+		"ActionProjectAddModule", GTK_STOCK_ADD,
+		N_("Add _Moduleâ?¦"), NULL, N_("Add a module to a target"),
+		G_CALLBACK (on_add_module)
+	},
+	{
+		"ActionProjectAddPackage", GTK_STOCK_ADD,
+		N_("Add _Packageâ?¦"), NULL, N_("Add a package to project"),
+		G_CALLBACK (on_add_package)
+	},
+	{
 		"ActionProjectAddGroup", GTK_STOCK_ADD,
 		N_("Add _Groupâ?¦"), NULL, N_("Add a group to project"),
 		G_CALLBACK (on_add_group)
@@ -947,6 +1019,16 @@ static GtkActionEntry popup_actions[] =
 		G_CALLBACK (on_popup_add_to_project)
 	},
 	{
+		"ActionPopupProjectAddModule", GTK_STOCK_ADD,
+		N_("Add _Module"), NULL, N_("Add a module to target"),
+		G_CALLBACK (on_popup_add_module)
+	},
+	{
+		"ActionPopupProjectAddPackage", GTK_STOCK_ADD,
+		N_("Add _Package"), NULL, N_("Add a package to project"),
+		G_CALLBACK (on_popup_add_package)
+	},
+	{
 		"ActionPopupProjectAddGroup", GTK_STOCK_ADD,
 		N_("Add _Group"), NULL, N_("Add a group to project"),
 		G_CALLBACK (on_popup_add_group)



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