Commit b3149b03 authored by Johannes Schmid's avatar Johannes Schmid Committed by Johannes Schmid

Use GtkComboBox instead of (deprecated) GtkOptionMenu and fixed broken

2007-08-31  Johannes Schmid <jhs@gnome.org>

	* libanjuta/anjuta-preferences.c: (get_object_type_from_string),
	(get_property_value_as_string), (set_property_value_as_string),
	(register_callbacks), (preferences_foreach_callback),
	(anjuta_preferences_register_property_raw):
	* libanjuta/anjuta-preferences.h:
	* plugins/build-basic-autotools/build-basic-autotools.c:
	(on_build_mesg_format):
	* plugins/document-manager/anjuta-document-manager.glade:
	* plugins/message-view/anjuta-message-manager-plugin.glade:
	
	Use GtkComboBox instead of (deprecated) GtkOptionMenu and fixed
	broken message view preferences
	
	* plugins/message-view/message-view.c:
	(message_view_instance_init), (pref_change_color), (prefs_init),
	(imessage_view_append):
	Cleaned up message view (#458041)
	
	* src/shell.c: (on_preferences_activate),
	(anjuta_test_shell_instance_init),
	(anjuta_test_shell_get_plugin_manager), (anjuta_shell_iface_init):
	Fixed test shell to allow better debugging

svn path=/trunk/; revision=3082
parent 51254986
2007-08-31 Johannes Schmid <jhs@gnome.org>
* libanjuta/anjuta-preferences.c: (get_object_type_from_string),
(get_property_value_as_string), (set_property_value_as_string),
(register_callbacks), (preferences_foreach_callback),
(anjuta_preferences_register_property_raw):
* libanjuta/anjuta-preferences.h:
* plugins/build-basic-autotools/build-basic-autotools.c:
(on_build_mesg_format):
* plugins/document-manager/anjuta-document-manager.glade:
* plugins/message-view/anjuta-message-manager-plugin.glade:
Use GtkComboBox instead of (deprecated) GtkOptionMenu and fixed
broken message view preferences
* plugins/message-view/message-view.c:
(message_view_instance_init), (pref_change_color), (prefs_init),
(imessage_view_append):
Cleaned up message view (#458041)
* src/shell.c: (on_preferences_activate),
(anjuta_test_shell_instance_init),
(anjuta_test_shell_get_plugin_manager), (anjuta_shell_iface_init):
Fixed test shell to allow better debugging
2007-08-31 Johannes Schmid <jhs@gnome.org>
* plugins/gtodo/interface.c: (gtodo_get_hide_done),
......
......@@ -508,8 +508,8 @@ get_object_type_from_string (const gchar* object_type)
{
if (strcmp (object_type, "entry") == 0)
return ANJUTA_PROPERTY_OBJECT_TYPE_ENTRY;
else if (strcmp (object_type, "menu") == 0)
return ANJUTA_PROPERTY_OBJECT_TYPE_MENU;
else if (strcmp (object_type, "combo") == 0)
return ANJUTA_PROPERTY_OBJECT_TYPE_COMBO;
else if (strcmp (object_type, "spin") == 0)
return ANJUTA_PROPERTY_OBJECT_TYPE_SPIN;
else if (strcmp (object_type, "toggle") == 0)
......@@ -577,11 +577,11 @@ get_property_value_as_string (AnjutaProperty *prop)
text_value =
gtk_editable_get_chars (GTK_EDITABLE (prop->object), 0, -1);
break;
case ANJUTA_PROPERTY_OBJECT_TYPE_MENU:
case ANJUTA_PROPERTY_OBJECT_TYPE_COMBO:
{
gint idx;
values = g_object_get_data(G_OBJECT(prop->object), "untranslated");
idx = gtk_option_menu_get_history(GTK_OPTION_MENU(prop->object));
idx = gtk_combo_box_get_active(GTK_COMBO_BOX(prop->object));
if (values[idx] != NULL)
text_value = g_strdup(values[idx]);
break;
......@@ -682,7 +682,7 @@ set_property_value_as_string (AnjutaProperty *prop, const gchar *value)
else
gtk_entry_set_text (GTK_ENTRY (prop->object), "");
break;
case ANJUTA_PROPERTY_OBJECT_TYPE_MENU:
case ANJUTA_PROPERTY_OBJECT_TYPE_COMBO:
values = g_object_get_data(G_OBJECT(prop->object), "untranslated");
if (value != NULL)
{
......@@ -690,7 +690,7 @@ set_property_value_as_string (AnjutaProperty *prop, const gchar *value)
{
if (strcmp(value, values[i]) == 0)
{
gtk_option_menu_set_history(GTK_OPTION_MENU(prop->object), i);
gtk_combo_box_set_active(GTK_COMBO_BOX(prop->object), i);
break;
}
}
......@@ -948,7 +948,7 @@ register_callbacks (AnjutaPreferences *pr, AnjutaProperty *p)
g_signal_connect (G_OBJECT(p->object), "focus_out_event",
G_CALLBACK (update_property_on_event_str), p);
break;
case ANJUTA_PROPERTY_OBJECT_TYPE_MENU:
case ANJUTA_PROPERTY_OBJECT_TYPE_COMBO:
g_signal_connect (G_OBJECT(p->object), "changed",
G_CALLBACK (update_property_on_change_str), p);
break;
......@@ -984,7 +984,7 @@ static gboolean
preferences_foreach_callback (gchar *key, struct _AnjutaProperty *p,
struct _AnjutaPreferencesForeachData *data)
{
if (p->object_type != ANJUTA_PROPERTY_OBJECT_TYPE_MENU)
if (p->object_type != ANJUTA_PROPERTY_OBJECT_TYPE_COMBO)
{
if (data->filter == ANJUTA_PREFERENCES_FILTER_NONE)
return data->callback (data->pr, key, data->callback_data);
......@@ -1080,8 +1080,8 @@ anjuta_preferences_register_property_raw (AnjutaPreferences *pr,
p->default_value = g_strdup (default_value);
if (strlen (default_value) > 0)
{
/* For menu, initialize the untranslated strings */
if (object_type == ANJUTA_PROPERTY_OBJECT_TYPE_MENU)
/* For combo, initialize the untranslated strings */
if (object_type == ANJUTA_PROPERTY_OBJECT_TYPE_COMBO)
{
gchar *old_value;
gchar **vstr;
......
......@@ -34,7 +34,7 @@ typedef enum
ANJUTA_PROPERTY_OBJECT_TYPE_TOGGLE,
ANJUTA_PROPERTY_OBJECT_TYPE_SPIN,
ANJUTA_PROPERTY_OBJECT_TYPE_ENTRY,
ANJUTA_PROPERTY_OBJECT_TYPE_MENU,
ANJUTA_PROPERTY_OBJECT_TYPE_COMBO,
ANJUTA_PROPERTY_OBJECT_TYPE_TEXT,
ANJUTA_PROPERTY_OBJECT_TYPE_COLOR,
ANJUTA_PROPERTY_OBJECT_TYPE_FONT
......
......@@ -668,7 +668,7 @@ on_build_mesg_format (IAnjutaMessageView *view, const gchar *one_line,
g_free (mid_str);
g_free (dummy_fn);
}
else if (strstr (line, ":") != NULL)
else if (strstr (line, ": ") != NULL)
{
type = IANJUTA_MESSAGE_VIEW_TYPE_INFO;
}
......
......@@ -649,7 +649,7 @@ message_view_instance_init (MessageView * self)
self->privat->line_buffer = g_strdup("");
/* Create the tree widget */
model = gtk_list_store_new (N_COLUMNS, GDK_TYPE_COLOR,
model = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING,
G_TYPE_STRING, MESSAGE_TYPE, G_TYPE_STRING);
self->privat->tree_view =
gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
......@@ -675,7 +675,7 @@ message_view_instance_init (MessageView * self)
gtk_tree_view_column_pack_start (column, renderer, TRUE);
gtk_tree_view_column_set_title (column, _("Messages"));
gtk_tree_view_column_add_attribute
(column, renderer, "foreground-gdk", COLUMN_COLOR);
(column, renderer, "foreground", COLUMN_COLOR);
gtk_tree_view_column_add_attribute
(column, renderer, "markup", COLUMN_SUMMARY);
gtk_tree_view_append_column (GTK_TREE_VIEW (self->privat->tree_view),
......@@ -1021,12 +1021,12 @@ static void
pref_change_color (MessageView *mview, IAnjutaMessageViewType type,
const gchar *color_pref_key)
{
GdkColor *color;
gchar* color;
GtkListStore *store;
GtkTreeIter iter;
gboolean success;
color = anjuta_util_convert_color (mview->privat->prefs, color_pref_key);
color = anjuta_preferences_get (mview->privat->prefs, color_pref_key);
store = GTK_LIST_STORE (gtk_tree_view_get_model
(GTK_TREE_VIEW (mview->privat->tree_view)));
success = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter);
......@@ -1044,14 +1044,6 @@ pref_change_color (MessageView *mview, IAnjutaMessageViewType type,
g_free(color);
}
static void
on_gconf_notify_color_info (GConfClient *gclient, guint cnxn_id,
GConfEntry *entry, gpointer user_data)
{
pref_change_color (MESSAGE_VIEW (user_data),
IANJUTA_MESSAGE_VIEW_TYPE_INFO,
"messages.color.info");
}
static void
on_gconf_notify_color_warning (GConfClient *gclient, guint cnxn_id,
......@@ -1080,7 +1072,6 @@ static void
prefs_init (MessageView *mview)
{
guint notify_id;
REGISTER_NOTIFY ("messages.color.info", on_gconf_notify_color_info);
REGISTER_NOTIFY ("messages.color.warning", on_gconf_notify_color_warning);
REGISTER_NOTIFY ("messages.color.error", on_gconf_notify_color_error);
}
......@@ -1152,7 +1143,7 @@ imessage_view_append (IAnjutaMessageView *message_view,
const gchar *details,
GError ** e)
{
GdkColor* color;
gchar* color;
GtkListStore *store;
GtkTreeIter iter;
gboolean highlite;
......@@ -1176,18 +1167,16 @@ imessage_view_append (IAnjutaMessageView *message_view,
switch (message->type)
{
case IANJUTA_MESSAGE_VIEW_TYPE_INFO:
color = anjuta_util_convert_color(view->privat->prefs,
"messages.color.info");
stock_id = GTK_STOCK_INFO;
break;
case IANJUTA_MESSAGE_VIEW_TYPE_WARNING:
color = anjuta_util_convert_color(view->privat->prefs,
color = anjuta_preferences_get (view->privat->prefs,
"messages.color.warning");
/* FIXME: There is no GTK_STOCK_WARNING which would fit better here */
stock_id = GTK_STOCK_DIALOG_WARNING;
break;
case IANJUTA_MESSAGE_VIEW_TYPE_ERROR:
color = anjuta_util_convert_color(view->privat->prefs,
color = anjuta_preferences_get (view->privat->prefs,
"messages.color.error");
stock_id = GTK_STOCK_STOP;
break;
......@@ -1216,23 +1205,21 @@ imessage_view_append (IAnjutaMessageView *message_view,
} else {
escaped_str = escape_string (message->summary);
}
if (color)
{
gtk_list_store_set (store, &iter,
COLUMN_COLOR, color,
gtk_list_store_set (store, &iter,
COLUMN_SUMMARY, escaped_str,
COLUMN_MESSAGE, message,
COLUMN_PIXBUF, stock_id,
-1);
/* Can we free the color when it's in the tree_view? */
// gdk_color_free (color);
} else {
if (color)
{
gtk_list_store_set (store, &iter,
COLUMN_SUMMARY, escaped_str,
COLUMN_MESSAGE, message,
-1);
COLUMN_COLOR, color, -1);
}
if (stock_id)
{
gtk_list_store_set (store, &iter,
COLUMN_PIXBUF, stock_id, -1);
}
g_free(color);
message_free (message);
g_free (utf8_msg);
g_free (escaped_str);
......
......@@ -52,7 +52,19 @@ on_exit_activate (GtkAction *action, AnjutaTestShell *shell)
static void
on_preferences_activate (GtkAction *action, AnjutaTestShell *shell)
{
gtk_widget_show (GTK_WIDGET (shell->preferences));
GtkWidget *preferences_dialog;
preferences_dialog = anjuta_preferences_get_dialog (shell->preferences);
g_signal_connect_swapped (G_OBJECT (preferences_dialog),
"response",
G_CALLBACK (gtk_widget_destroy),
preferences_dialog);
gtk_window_set_transient_for (GTK_WINDOW (preferences_dialog),
GTK_WINDOW (shell));
gtk_widget_show (preferences_dialog);
}
static void
......@@ -164,8 +176,8 @@ anjuta_test_shell_instance_init (AnjutaTestShell *shell)
"add_widget", G_CALLBACK (on_add_merge_widget),
shell);
gtk_window_add_accel_group (GTK_WINDOW (shell),
anjuta_ui_get_accel_group (shell->ui));
/*gtk_window_add_accel_group (GTK_WINDOW (shell),
anjuta_ui_get_accel_group (shell->ui));*/
/* Register actions */
anjuta_ui_add_action_group_entries (shell->ui, "ActionGroupTestShell",
_("Test shell action group"),
......@@ -280,6 +292,12 @@ anjuta_test_shell_remove_widget (AnjutaShell *shell,
//}
}
static AnjutaPluginManager*
anjuta_test_shell_get_plugin_manager (AnjutaShell *shell, GError **error)
{
return ANJUTA_TEST_SHELL(shell)->plugin_manager;
}
static void
anjuta_test_shell_present_widget (AnjutaShell *shell,
GtkWidget *w,
......@@ -392,6 +410,7 @@ anjuta_shell_iface_init (AnjutaShellIface *iface)
iface->get_status = anjuta_test_shell_get_status;
iface->get_ui = anjuta_test_shell_get_ui;
iface->get_preferences = anjuta_test_shell_get_preferences;
iface->get_plugin_manager = anjuta_test_shell_get_plugin_manager;
}
ANJUTA_TYPE_BEGIN(AnjutaTestShell, anjuta_test_shell, GTK_TYPE_WINDOW);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment