[anjuta] gbf-am: Use AnjutaPkgConfigChooser instead of custom widget
- From: Johannes Schmid <jhs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] gbf-am: Use AnjutaPkgConfigChooser instead of custom widget
- Date: Sun, 11 Jul 2010 09:05:32 +0000 (UTC)
commit 84877d8064838dc73e9801d957642fe499fa43ef
Author: Johannes Schmid <jhs gnome org>
Date: Sun Jul 11 11:04:29 2010 +0200
gbf-am: Use AnjutaPkgConfigChooser instead of custom widget
plugins/gbf-am/gbf-am-dialogs.ui | 216 ++++++++++++++++++------------------
plugins/gbf-am/gbf-am-properties.c | 93 +---------------
2 files changed, 116 insertions(+), 193 deletions(-)
---
diff --git a/plugins/gbf-am/gbf-am-dialogs.ui b/plugins/gbf-am/gbf-am-dialogs.ui
index 120b26b..cffd6a7 100644
--- a/plugins/gbf-am/gbf-am-dialogs.ui
+++ b/plugins/gbf-am/gbf-am-dialogs.ui
@@ -1,7 +1,116 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
<interface>
+ <!-- interface-requires anjuta 0.0 -->
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy toplevel-contextual -->
+ <object class="GtkDialog" id="package_selection_dialog">
+ <property name="title" translatable="yes">Select package</property>
+ <property name="default_width">600</property>
+ <property name="default_height">500</property>
+ <property name="type_hint">dialog</property>
+ <child internal-child="vbox">
+ <object class="GtkVBox" id="dialog-vbox1">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkVBox" id="vbox2">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkFrame" id="frame1">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment3">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow2">
+ <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="AnjutaPkgConfigChooser" id="pkg_treeview">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="headers_visible">False</property>
+ <property name="headers_clickable">False</property>
+ <property name="search_column">0</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Select Package to add:</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkHButtonBox" id="dialog-action_area1">
+ <property name="visible">True</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="cancelbutton1">
+ <property name="label">gtk-cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="okbutton1">
+ <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">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">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="-6">cancelbutton1</action-widget>
+ <action-widget response="-3">okbutton1</action-widget>
+ </action-widgets>
+ </object>
<object class="GtkWindow" id="project_properties_dialog">
<property name="title" translatable="yes">window1</property>
<child>
@@ -311,109 +420,4 @@
</object>
</child>
</object>
- <object class="GtkDialog" id="package_selection_dialog">
- <property name="title" translatable="yes">Select package</property>
- <property name="default_width">600</property>
- <property name="default_height">500</property>
- <property name="type_hint">dialog</property>
- <child internal-child="vbox">
- <object class="GtkVBox" id="dialog-vbox1">
- <property name="visible">True</property>
- <child>
- <object class="GtkVBox" id="vbox2">
- <property name="visible">True</property>
- <child>
- <object class="GtkFrame" id="frame1">
- <property name="visible">True</property>
- <property name="label_xalign">0</property>
- <property name="shadow_type">none</property>
- <child>
- <object class="GtkAlignment" id="alignment3">
- <property name="visible">True</property>
- <property name="left_padding">12</property>
- <child>
- <object class="GtkScrolledWindow" id="scrolledwindow2">
- <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="pkg_treeview">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child type="label">
- <object class="GtkLabel" id="label5">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Select Package to add:</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- </child>
- </object>
- <packing>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="position">2</property>
- </packing>
- </child>
- <child internal-child="action_area">
- <object class="GtkHButtonBox" id="dialog-action_area1">
- <property name="visible">True</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="cancelbutton1">
- <property name="label">gtk-cancel</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="okbutton1">
- <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">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">end</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- </child>
- <action-widgets>
- <action-widget response="-6">cancelbutton1</action-widget>
- <action-widget response="-3">okbutton1</action-widget>
- </action-widgets>
- </object>
</interface>
diff --git a/plugins/gbf-am/gbf-am-properties.c b/plugins/gbf-am/gbf-am-properties.c
index df7d87b..a216ac1 100644
--- a/plugins/gbf-am/gbf-am-properties.c
+++ b/plugins/gbf-am/gbf-am-properties.c
@@ -35,6 +35,7 @@
#include <glib/gi18n.h>
#include <libanjuta/anjuta-debug.h>
+#include <libanjuta/anjuta-pkg-config-chooser.h>
#include "gbf-am-config.h"
#include "gbf-am-properties.h"
@@ -182,62 +183,6 @@ recursive_config_foreach_cb (const gchar *key, GbfAmConfigValue *value,
GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 3);
}
-static GtkListStore *
-packages_get_pkgconfig_list (void)
-{
- GtkListStore *store;
- GtkTreeIter iter;
- gchar line[1024];
- gchar *tmpfile, *pkg_cmd;
- FILE *pkg_fd;
-
- store = gtk_list_store_new (N_PKG_COLUMNS, G_TYPE_STRING,
- G_TYPE_STRING);
-
- /* Now get all the pkg-config info */
- tmpfile = g_strdup_printf ("%s%cpkgmodules--%d", g_get_tmp_dir (),
- G_DIR_SEPARATOR, getpid());
- pkg_cmd = g_strconcat ("pkg-config --list-all 2>/dev/null | sort > ",
- tmpfile, NULL);
- if (system (pkg_cmd) == -1)
- return store;
- pkg_fd = fopen (tmpfile, "r");
- if (!pkg_fd) {
- g_warning ("Can not open %s for reading", tmpfile);
- g_free (tmpfile);
- return store;
- }
- while (fgets (line, 1024, pkg_fd)) {
- gchar *name_end;
- gchar *desc_start;
- gchar *description;
- gchar *name;
-
- if (line[0] == '\0')
- continue;
-
- name_end = line;
- while (!isspace(*name_end))
- name_end++;
- desc_start = name_end;
- while (isspace(*desc_start))
- desc_start++;
-
- name = g_strndup (line, name_end-line);
- description = g_strndup (desc_start, strlen (desc_start)-1);
-
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter,
- COL_PKG_PACKAGE, name,
- COL_PKG_DESCRIPTION, description,
- -1);
- }
- fclose (pkg_fd);
- unlink (tmpfile);
- g_free (tmpfile);
- return store;
-}
-
static void
save_packages_list (GbfAmProject *project, GbfAmConfigMapping *config,
GtkTreeModel *model, GtkTreeIter *parent)
@@ -417,9 +362,6 @@ add_package_clicked_cb (GtkWidget *button, GbfAmProject *project)
GtkTreePath *path;
GtkWidget *dlg;
GtkWidget *pkg_treeview;
- GtkListStore *store;
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *col;
gchar *pkg_to_add = NULL;
GbfAmConfigMapping *config;
GError* error = NULL;
@@ -433,36 +375,13 @@ add_package_clicked_cb (GtkWidget *button, GbfAmProject *project)
dlg = GTK_WIDGET (gtk_builder_get_object (bxml, "package_selection_dialog"));
pkg_treeview = GTK_WIDGET (gtk_builder_get_object (bxml, "pkg_treeview"));
- renderer = gtk_cell_renderer_text_new ();
- col = gtk_tree_view_column_new_with_attributes (_("Module/Packages"),
- 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 (pkg_treeview), col);
- renderer = gtk_cell_renderer_text_new ();
- col = gtk_tree_view_column_new_with_attributes (_("Version"),
- renderer,
- "text",
- COL_PKG_DESCRIPTION,
- NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (pkg_treeview), col);
+ anjuta_pkg_config_chooser_show_active_column (ANJUTA_PKG_CONFIG_CHOOSER (pkg_treeview),
+ FALSE);
- store = packages_get_pkgconfig_list ();
- gtk_tree_view_set_model (GTK_TREE_VIEW (pkg_treeview),
- GTK_TREE_MODEL (store));
if (gtk_dialog_run (GTK_DIALOG (dlg)) == GTK_RESPONSE_ACCEPT)
- {
- GtkTreeSelection *sel;
- GtkTreeIter pkg_iter;
-
- sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (pkg_treeview));
- if (gtk_tree_selection_get_selected (sel, NULL, &pkg_iter))
- {
- gtk_tree_model_get (GTK_TREE_MODEL (store),
- &pkg_iter, COL_PKG_PACKAGE,
- &pkg_to_add, -1);
- }
+ {
+ pkg_to_add =
+ anjuta_pkg_config_chooser_get_selected_package (ANJUTA_PKG_CONFIG_CHOOSER (pkg_treeview));
}
gtk_widget_destroy (dlg);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]