anjuta r3806 - in trunk: . plugins/tools
- From: jhs svn gnome org
- To: svn-commits-list gnome org
- Subject: anjuta r3806 - in trunk: . plugins/tools
- Date: Mon, 31 Mar 2008 14:14:57 +0100 (BST)
Author: jhs
Date: Mon Mar 31 14:14:57 2008
New Revision: 3806
URL: http://svn.gnome.org/viewvc/anjuta?rev=3806&view=rev
Log:
2008-03-31 Johannes Schmid <jhs gnome org>
patch by: Yuriy Penkin <yuriy penkin gmail com>
* plugins/tools/anjuta-tools.glade:
* plugins/tools/anjuta-tools.ui:
* plugins/tools/dialog.c (TOOL_LIST, TOOL_TREEVIEW, TOOL_EDIT_BUTTON,
TOOL_DELETE_BUTTON, TOOL_UP_BUTTON, TOOL_DOWN_BUTTON,
atp_tool_dialog_refresh, atp_tool_dialog_show):
* plugins/tools/dialog.h (dialog, plugin):
* plugins/tools/plugin.c (prefs, gxml, action_group,
atp_plugin_finalize, test, atp_plugin_activate,
atp_plugin_deactivate, atp_plugin_class_init, ipreferences_merge,
ipreferences_unmerge, ipreferences_iface_init):
* plugins/tools/tool.c (action, action_group, accel_key, accel_mods,
icon, merge_id, atp_user_tool_free, atp_user_tool_deactivate,
atp_user_tool_activate, atp_tool_list_append_new,
atp_tool_list_activate, atp_tool_list_deactivate):
* plugins/tools/tool.h (plugin):
#515854 â Move configuration into preferences
Modified:
trunk/ChangeLog
trunk/plugins/tools/anjuta-tools.glade
trunk/plugins/tools/anjuta-tools.ui
trunk/plugins/tools/dialog.c
trunk/plugins/tools/dialog.h
trunk/plugins/tools/plugin.c
trunk/plugins/tools/tool.c
trunk/plugins/tools/tool.h
Modified: trunk/plugins/tools/anjuta-tools.glade
==============================================================================
--- trunk/plugins/tools/anjuta-tools.glade (original)
+++ trunk/plugins/tools/anjuta-tools.glade Mon Mar 31 14:14:57 2008
@@ -1,188 +1,142 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--*- mode: xml -*-->
+<!--Generated with glade3 3.4.2 on Mon Mar 31 15:12:40 2008 -->
<glade-interface>
<requires lib="gnome"/>
- <widget class="GtkDialog" id="list_dialog">
- <property name="visible">True</property>
- <property name="title" translatable="yes">User Tools</property>
- <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
- <property name="skip_pager_hint">True</property>
- <signal name="response" handler="on_list_dialog_response"/>
- <child internal-child="vbox">
- <widget class="GtkVBox" id="dialog-vbox1">
+ <widget class="GtkWindow" id="list_tools">
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <child>
+ <widget class="GtkFrame" id="Tools">
<property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
- <widget class="GtkLabel" id="label44">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="xpad">5</property>
- <property name="ypad">2</property>
- <property name="label" translatable="yes">Menu Items:</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <widget class="GtkHBox" id="hbox2">
+ <widget class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="left_padding">12</property>
<child>
- <widget class="GtkScrolledWindow" id="scrolledwindow16">
- <property name="width_request">256</property>
+ <widget class="GtkHBox" id="hbox1">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="border_width">5</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>
- <child>
- <widget class="GtkTreeView" id="tools_treeview">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="headers_visible">False</property>
- <signal name="row_activated" handler="on_tool_activated"/>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkVButtonBox" id="vbuttonbox2">
- <property name="visible">True</property>
- <property name="border_width">5</property>
- <property name="spacing">5</property>
- <property name="layout_style">GTK_BUTTONBOX_START</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
- <widget class="GtkButton" id="edit_bt">
+ <widget class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="response_id">0</property>
- <signal name="clicked" handler="on_tool_edit"/>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</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>
<child>
- <widget class="GtkAlignment" id="alignment9">
+ <widget class="GtkTreeView" id="tools_treeview">
<property name="visible">True</property>
- <property name="xscale">0</property>
- <property name="yscale">0</property>
- <child>
- <widget class="GtkHBox" id="hbox24">
- <property name="visible">True</property>
- <property name="spacing">2</property>
- <child>
- <widget class="GtkImage" id="image9">
- <property name="visible">True</property>
- <property name="stock">gtk-preferences</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel" id="label102">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Edit</property>
- <property name="use_underline">True</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- </child>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK</property>
+ <property name="headers_clickable">True</property>
+ <signal name="row_activated" handler="on_tool_activated"/>
</widget>
</child>
</widget>
</child>
<child>
- <widget class="GtkButton" id="add_bt">
+ <widget class="GtkVButtonBox" id="vbuttonbox1">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="label">gtk-add</property>
- <property name="use_stock">True</property>
- <property name="response_id">0</property>
- <signal name="clicked" handler="on_tool_add"/>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="border_width">5</property>
+ <property name="spacing">5</property>
+ <property name="layout_style">GTK_BUTTONBOX_START</property>
+ <child>
+ <widget class="GtkButton" id="edit_bt">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">gtk-preferences</property>
+ <property name="use_stock">True</property>
+ <property name="response_id">0</property>
+ <signal name="clicked" handler="on_tool_edit"/>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkButton" id="add_bt">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">gtk-add</property>
+ <property name="use_stock">True</property>
+ <property name="response_id">0</property>
+ <signal name="clicked" handler="on_tool_add"/>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="delete_bt">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">gtk-remove</property>
+ <property name="use_stock">True</property>
+ <property name="response_id">0</property>
+ <signal name="clicked" handler="on_tool_delete"/>
+ </widget>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="up_bt">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">gtk-go-up</property>
+ <property name="use_stock">True</property>
+ <property name="response_id">0</property>
+ <signal name="clicked" handler="on_tool_up"/>
+ </widget>
+ <packing>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="down_bt">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">gtk-go-down</property>
+ <property name="use_stock">True</property>
+ <property name="response_id">0</property>
+ <signal name="clicked" handler="on_tool_down"/>
+ </widget>
+ <packing>
+ <property name="position">4</property>
+ </packing>
+ </child>
</widget>
<packing>
+ <property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
- <child>
- <widget class="GtkButton" id="delete_bt">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="label">gtk-remove</property>
- <property name="use_stock">True</property>
- <property name="response_id">0</property>
- <signal name="clicked" handler="on_tool_delete"/>
- </widget>
- <packing>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <widget class="GtkButton" id="up_bt">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="label">gtk-go-up</property>
- <property name="use_stock">True</property>
- <property name="response_id">0</property>
- <signal name="clicked" handler="on_tool_up"/>
- </widget>
- <packing>
- <property name="position">3</property>
- </packing>
- </child>
- <child>
- <widget class="GtkButton" id="down_bt">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="label">gtk-go-down</property>
- <property name="use_stock">True</property>
- <property name="response_id">0</property>
- <signal name="clicked" handler="on_tool_down"/>
- </widget>
- <packing>
- <property name="position">4</property>
- </packing>
- </child>
</widget>
- <packing>
- <property name="expand">False</property>
- <property name="position">1</property>
- </packing>
</child>
</widget>
- <packing>
- <property name="position">3</property>
- </packing>
</child>
- <child internal-child="action_area">
- <widget class="GtkHButtonBox" id="dialog-action_area1">
+ <child>
+ <widget class="GtkLabel" id="label1">
<property name="visible">True</property>
- <property name="layout_style">GTK_BUTTONBOX_END</property>
- <child>
- <widget class="GtkButton" id="button1">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="label">gtk-close</property>
- <property name="use_stock">True</property>
- <property name="response_id">-7</property>
- </widget>
- </child>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes"><b>Tools</b></property>
+ <property name="use_markup">True</property>
</widget>
<packing>
- <property name="expand">False</property>
- <property name="pack_type">GTK_PACK_END</property>
+ <property name="type">label_item</property>
</packing>
</child>
</widget>
@@ -429,7 +383,6 @@
<widget class="GtkToggleButton" id="shortcut_bt">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="label"></property>
<property name="use_underline">True</property>
<property name="focus_on_click">False</property>
<property name="response_id">0</property>
@@ -687,6 +640,7 @@
<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>
<child>
<widget class="GtkTreeView" id="variable_treeview">
<property name="visible">True</property>
Modified: trunk/plugins/tools/anjuta-tools.ui
==============================================================================
--- trunk/plugins/tools/anjuta-tools.ui (original)
+++ trunk/plugins/tools/anjuta-tools.ui Mon Mar 31 14:14:57 2008
@@ -3,7 +3,6 @@
<menubar name="MenuMain">
<placeholder name="PlaceHolderToolMenus">
<menu name="MenuTools" action="ActionMenuTools">
- <menuitem name="Configure" action="ActionConfigureTools" />
<separator name="separator1" />
</menu>
</placeholder>
Modified: trunk/plugins/tools/dialog.c
==============================================================================
--- trunk/plugins/tools/dialog.c (original)
+++ trunk/plugins/tools/dialog.c Mon Mar 31 14:14:57 2008
@@ -36,14 +36,13 @@
/* Widget and signal name found in glade file
*---------------------------------------------------------------------------*/
-#define TOOL_LIST "list_dialog"
+#define TOOL_LIST "list_tools"
#define TOOL_TREEVIEW "tools_treeview"
#define TOOL_EDIT_BUTTON "edit_bt"
#define TOOL_DELETE_BUTTON "delete_bt"
#define TOOL_UP_BUTTON "up_bt"
#define TOOL_DOWN_BUTTON "down_bt"
-#define LIST_RESPONSE_SIGNAL "on_list_dialog_response"
#define TOOL_ADD_SIGNAL "on_tool_add"
#define TOOL_ACTIVATED_SIGNAL "on_tool_activated"
#define TOOL_EDIT_SIGNAL "on_tool_edit"
@@ -258,18 +257,6 @@
update_sensitivity (this);
}
-static void
-on_list_response (GtkDialog *dialog, gint res, gpointer user_data)
-{
- ATPToolDialog *this = (ATPToolDialog *)user_data;
-
- /* Just save tool list */
- atp_anjuta_tools_save(this->plugin);
-
- /* Close widget */
- atp_tool_dialog_close (this);
-}
-
/* Public functions
*---------------------------------------------------------------------------*/
@@ -314,34 +301,22 @@
/* Restore changed signal */
g_signal_handler_unblock (selection, this->changed_sig);
update_sensitivity(this);
+
+ /* Just save tool list */
+ atp_anjuta_tools_save(this->plugin);
}
/* Start the tool lister and editor */
-gboolean
-atp_tool_dialog_show (ATPToolDialog* this)
+void
+atp_tool_dialog_show (ATPToolDialog* this, GladeXML *xml)
{
- GladeXML *xml;
GtkTreeModel *model;
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
GtkTreeSelection *selection;
- if (this->dialog != NULL)
- {
- /* dialog is already displayed */
- gtk_window_present (GTK_WINDOW (this->dialog));
- return FALSE;
- }
-
- /* Load glade file */
- if (NULL == (xml = glade_xml_new(GLADE_FILE, TOOL_LIST, NULL)))
- {
- anjuta_util_dialog_error(atp_plugin_get_app_window (this->plugin), _("Unable to build user interface for tool list"));
- return FALSE;
- }
- this->dialog = GTK_DIALOG(glade_xml_get_widget(xml, TOOL_LIST));
- gtk_widget_show (GTK_WIDGET(this->dialog));
+ this->dialog = GTK_WINDOW (glade_xml_get_widget(xml, TOOL_LIST));
gtk_window_set_transient_for (GTK_WINDOW (this->dialog), atp_plugin_get_app_window (this->plugin));
/* Create tree view */
@@ -368,8 +343,7 @@
this->up_bt = glade_xml_get_widget(xml, TOOL_UP_BUTTON);
this->down_bt = glade_xml_get_widget(xml, TOOL_DOWN_BUTTON);
- /* Connect all signals */
- glade_xml_signal_connect_data (xml, LIST_RESPONSE_SIGNAL, GTK_SIGNAL_FUNC (on_list_response), this);
+ /* Connect all signals */
glade_xml_signal_connect_data (xml, TOOL_ADD_SIGNAL, GTK_SIGNAL_FUNC (on_tool_add), this);
glade_xml_signal_connect_data (xml, TOOL_ACTIVATED_SIGNAL, GTK_SIGNAL_FUNC (on_tool_activated), this);
glade_xml_signal_connect_data (xml, TOOL_EDIT_SIGNAL, GTK_SIGNAL_FUNC (on_tool_edit), this);
@@ -379,11 +353,7 @@
selection = gtk_tree_view_get_selection (this->view);
this->changed_sig = g_signal_connect (G_OBJECT (selection), "changed", G_CALLBACK (on_tool_selection_changed), this);
- g_object_unref (xml);
-
atp_tool_dialog_refresh (this, NULL);
-
- return TRUE;
}
void
Modified: trunk/plugins/tools/dialog.h
==============================================================================
--- trunk/plugins/tools/dialog.h (original)
+++ trunk/plugins/tools/dialog.h Mon Mar 31 14:14:57 2008
@@ -30,7 +30,7 @@
typedef struct _ATPToolDialog ATPToolDialog;
struct _ATPToolDialog {
- GtkDialog* dialog;
+ GtkWindow* dialog;
GtkTreeView* view;
gboolean changed_sig ;
GtkWidget *edit_bt;
@@ -49,7 +49,7 @@
ATPVariable* atp_tool_dialog_get_variable (const ATPToolDialog *this);
-gboolean atp_tool_dialog_show (ATPToolDialog *this);
+void atp_tool_dialog_show (ATPToolDialog *this, GladeXML *xml);
void atp_tool_dialog_close (ATPToolDialog *this);
#endif
Modified: trunk/plugins/tools/plugin.c
==============================================================================
--- trunk/plugins/tools/plugin.c (original)
+++ trunk/plugins/tools/plugin.c Mon Mar 31 14:14:57 2008
@@ -97,6 +97,8 @@
#include <libanjuta/anjuta-shell.h>
#include <libanjuta/anjuta-debug.h>
+#include <libanjuta/interfaces/ianjuta-preferences.h>
+
/*---------------------------------------------------------------------------*/
#define ICON_FILE "anjuta-tools-plugin-48.png"
@@ -106,6 +108,9 @@
struct _ATPPlugin {
AnjutaPlugin parent;
+ AnjutaPreferences *prefs;
+ GladeXML *gxml;
+ GtkActionGroup* action_group;
gint uiid;
ATPToolList list;
ATPToolDialog dialog;
@@ -117,15 +122,6 @@
AnjutaPluginClass parent_class;
};
-/* Call backs
- *---------------------------------------------------------------------------*/
-
-static void
-atp_on_menu_tools_configure (GtkAction* action, ATPPlugin* plugin)
-{
- atp_tool_dialog_show(&plugin->dialog);
-};
-
/*---------------------------------------------------------------------------*/
static GtkActionEntry actions_tools[] = {
@@ -136,14 +132,6 @@
NULL, /* Short-cut */
NULL, /* Tooltip */
NULL /* Callback */
- },
- {
- "ActionConfigureTools",
- NULL,
- N_("_Configure"),
- NULL,
- N_("Configure external tools"),
- G_CALLBACK (atp_on_menu_tools_configure)
}
};
@@ -177,33 +165,30 @@
/* finalize used to free object created with instance init is not used */
+
+static void test (GtkAction *action)
+{
+}
+
static gboolean
atp_plugin_activate (AnjutaPlugin *plugin)
{
ATPPlugin *this = ANJUTA_PLUGIN_ATP (plugin);
AnjutaUI *ui;
- GtkMenu* menu;
- GtkWidget* sep;
+ GtkAction *action;
DEBUG_PRINT ("Tools Plugin: Activating tools plugin...");
-
+
/* Add all our actions */
ui = anjuta_shell_get_ui (plugin->shell, NULL);
- anjuta_ui_add_action_group_entries (ui, "ActionGroupTools",
+ this->action_group = anjuta_ui_add_action_group_entries (ui,
+ "ActionGroupTools",
_("Tool operations"),
actions_tools,
G_N_ELEMENTS (actions_tools),
GETTEXT_PACKAGE, TRUE, plugin);
this->uiid = anjuta_ui_merge (ui, UI_FILE);
- /* Load tools */
- menu = GTK_MENU (gtk_menu_item_get_submenu (GTK_MENU_ITEM (gtk_ui_manager_get_widget (GTK_UI_MANAGER(ui), MENU_PLACEHOLDER))));
-
- /* Add a separator */
- sep = gtk_separator_menu_item_new();
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), sep);
- gtk_widget_show (sep);
-
/* Add tool menu item */
atp_tool_list_construct (&this->list, this);
atp_anjuta_tools_load (this);
@@ -213,7 +198,9 @@
atp_tool_dialog_construct (&this->dialog, this);
atp_variable_construct (&this->variable, plugin->shell);
atp_context_list_construct (&this->context);
-
+
+ atp_tool_list_activate (atp_plugin_get_tool_list (this->dialog.plugin));
+
return TRUE;
}
@@ -225,6 +212,7 @@
DEBUG_PRINT ("Tools Plugin: Deactivating tools plugin...");
+ atp_tool_list_deactivate (&this->list);
atp_context_list_destroy (&this->context);
atp_variable_destroy (&this->variable);
atp_tool_dialog_destroy (&this->dialog);
@@ -233,6 +221,8 @@
ui = anjuta_shell_get_ui (plugin->shell, NULL);
anjuta_ui_unmerge (ui, this->uiid);
+ g_object_unref (this->gxml);
+
return TRUE;
}
@@ -249,7 +239,44 @@
klass->finalize = atp_plugin_finalize;
}
-ANJUTA_PLUGIN_BOILERPLATE (ATPPlugin, atp_plugin);
+static void
+ipreferences_merge(IAnjutaPreferences* obj, AnjutaPreferences* prefs, GError** e)
+{
+ /* Create the tools preferences page */
+ ATPPlugin* atp_plugin;
+
+ atp_plugin = ANJUTA_PLUGIN_ATP (obj);
+ atp_plugin->prefs = anjuta_shell_get_preferences (ANJUTA_PLUGIN(obj)->shell,
+ NULL);
+
+ /* Load glade file */
+ atp_plugin->gxml = glade_xml_new (GLADE_FILE, "list_tools", NULL);
+ if (atp_plugin->gxml == NULL)
+ return FALSE;
+
+ atp_tool_dialog_show(&atp_plugin->dialog, atp_plugin->gxml);
+
+ anjuta_preferences_add_page (atp_plugin->prefs, atp_plugin->gxml,
+ "Tools", _("Tools"), ICON_FILE);
+}
+
+static void
+ipreferences_unmerge(IAnjutaPreferences* obj, AnjutaPreferences* prefs, GError** e)
+{
+ anjuta_preferences_remove_page (prefs, "Tools");
+}
+
+static void
+ipreferences_iface_init(IAnjutaPreferencesIface* iface)
+{
+ iface->merge = ipreferences_merge;
+ iface->unmerge = ipreferences_unmerge;
+}
+
+ANJUTA_PLUGIN_BEGIN (ATPPlugin, atp_plugin);
+ANJUTA_PLUGIN_ADD_INTERFACE (ipreferences, IANJUTA_TYPE_PREFERENCES);
+ANJUTA_PLUGIN_END;
+
ANJUTA_SIMPLE_PLUGIN (ATPPlugin, atp_plugin);
/* Access plugin variables
Modified: trunk/plugins/tools/tool.c
==============================================================================
--- trunk/plugins/tools/tool.c (original)
+++ trunk/plugins/tools/tool.c Mon Mar 31 14:14:57 2008
@@ -62,9 +62,12 @@
gchar *input_string;
ATPToolStore storage;
GtkWidget* menu_item;
+ GtkAction *action;
+ GtkActionGroup *action_group;
guint accel_key;
GdkModifierType accel_mods;
gchar *icon;
+ guint merge_id;
ATPToolList *owner;
ATPUserTool *over; /* Same tool in another storage */
ATPUserTool *next; /* Next tool in the list */
@@ -428,7 +431,7 @@
g_return_if_fail (this->owner);
atp_user_tool_remove (this);
- atp_user_tool_deactivate (this);
+ atp_user_tool_deactivate (this, this->owner->ui);
g_chunk_free (this, this->owner->data_pool);
}
@@ -711,31 +714,59 @@
}
void
-atp_user_tool_deactivate (ATPUserTool* this)
+atp_user_tool_deactivate (ATPUserTool* this, AnjutaUI *ui)
{
- /* accelerator is destroyed with the widget */
- if (this->menu_item)
+ if (this->merge_id != 0)
{
- gtk_widget_destroy (this->menu_item);
- this->menu_item = NULL;
+ gtk_ui_manager_remove_ui (GTK_UI_MANAGER (ui), this->merge_id);
+ gtk_ui_manager_remove_action_group (GTK_UI_MANAGER (ui), this->action_group);
}
}
gboolean
-atp_user_tool_activate (ATPUserTool *this, GtkMenu *submenu, GtkAccelGroup *group)
+atp_user_tool_activate (ATPUserTool *this, GtkAccelGroup *group, AnjutaUI *ui)
{
+ gchar *menuitem_path;
+
/* Remove previous menu */
- atp_user_tool_deactivate (this);
+ atp_user_tool_deactivate (this, ui);
/* Create new menu item */
- this->menu_item = gtk_image_menu_item_new_with_mnemonic (this->name);
- gtk_widget_set_sensitive (this->menu_item, this->flags & ATP_TOOL_ENABLE);
+ this->action = gtk_action_new (this->name, this->name, this->name, NULL);
+ this->action_group = gtk_action_group_new ("ActionGroupTools");
+
+ if (this->accel_key != 0)
+ {
+ gchar *accelerator;
+
+ accelerator = gtk_accelerator_name (this->accel_key, this->accel_mods);
+ gtk_action_group_add_action_with_accel (this->action_group, this->action, accelerator);
+ }
+ else
+ {
+ gtk_action_group_add_action (this->action_group, this->action);
+ }
+
+ gtk_ui_manager_insert_action_group (GTK_UI_MANAGER (ui), this->action_group, 0);
+
+ this->merge_id = gtk_ui_manager_new_merge_id (GTK_UI_MANAGER (ui));
+ gtk_ui_manager_add_ui (GTK_UI_MANAGER (ui),
+ this->merge_id,
+ MENU_PLACEHOLDER,
+ this->name,
+ this->name,
+ GTK_UI_MANAGER_MENUITEM,
+ FALSE);
+
+ menuitem_path = g_strconcat (MENU_PLACEHOLDER, "/", this->name, NULL);
+ this->menu_item = gtk_ui_manager_get_widget (GTK_UI_MANAGER (ui), menuitem_path);
+ gtk_action_set_sensitive (this->action, this->flags & ATP_TOOL_ENABLE);
/* Add icon */
if ((this->menu_item != NULL) && (this->icon != NULL))
{
GdkPixbuf *pixbuf;
- GdkPixbuf *scaled_pixbuf;
+ GdkPixbuf *scaled_pixbuf;
gint height, width;
gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (this->menu_item), GTK_ICON_SIZE_MENU, &width, &height);
@@ -753,15 +784,7 @@
}
}
- g_signal_connect (G_OBJECT (this->menu_item), "activate", G_CALLBACK (atp_user_tool_execute), this);
-
- if (this->accel_key != 0)
- {
- gtk_widget_add_accelerator(this->menu_item, "activate", group, this->accel_key, this->accel_mods, GTK_ACCEL_VISIBLE);
- }
-
- gtk_menu_shell_append (GTK_MENU_SHELL (submenu), this->menu_item);
- gtk_widget_show(this->menu_item);
+ g_signal_connect (G_OBJECT (this->action), "activate", G_CALLBACK (atp_user_tool_execute), this);
return TRUE;
}
@@ -883,18 +906,30 @@
return tool;
}
-gboolean atp_tool_list_activate (ATPToolList *this)
+gboolean
+atp_tool_list_activate (ATPToolList *this)
{
ATPUserTool *next;
- GtkMenu* menu;
GtkAccelGroup* group;
- menu = GTK_MENU (gtk_menu_item_get_submenu (GTK_MENU_ITEM (gtk_ui_manager_get_widget (GTK_UI_MANAGER(this->ui), MENU_PLACEHOLDER))));
- group = anjuta_ui_get_accel_group(this->ui);
+ group = anjuta_ui_get_accel_group (this->ui);
+
+ for (next = atp_tool_list_first (this); next != NULL; next = atp_user_tool_next (next))
+ {
+ atp_user_tool_activate (next, group, this->ui);
+ }
+
+ return TRUE;
+}
+
+gboolean
+atp_tool_list_deactivate (ATPToolList *this)
+{
+ ATPUserTool *next;
for (next = atp_tool_list_first (this); next != NULL; next = atp_user_tool_next (next))
{
- atp_user_tool_activate (next, menu, group);
+ atp_user_tool_deactivate (next, next->owner->ui);
}
return TRUE;
Modified: trunk/plugins/tools/tool.h
==============================================================================
--- trunk/plugins/tools/tool.h (original)
+++ trunk/plugins/tools/tool.h Mon Mar 31 14:14:57 2008
@@ -117,8 +117,8 @@
ATPUserTool *atp_user_tool_append_new (ATPUserTool* this, const gchar *name, ATPToolStore storage);
ATPUserTool *atp_user_tool_clone_new (ATPUserTool* this, ATPToolStore storage);
-gboolean atp_user_tool_activate (ATPUserTool* this, GtkMenu* submenu, GtkAccelGroup* group);
-void atp_user_tool_deactivate (ATPUserTool* this);
+gboolean atp_user_tool_activate (ATPUserTool* this, GtkAccelGroup* group, AnjutaUI *ui);
+void atp_user_tool_deactivate (ATPUserTool* this, AnjutaUI *ui);
gboolean atp_user_tool_move_after (ATPUserTool* this, ATPUserTool* position);
@@ -174,6 +174,7 @@
ATPUserTool* atp_tool_list_last (ATPToolList *this);
gboolean atp_tool_list_activate (ATPToolList *this);
+gboolean atp_tool_list_deactivate (ATPToolList *this);
ATPUserTool *atp_tool_list_append_new (ATPToolList* this, const gchar *name, ATPToolStore storage);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]