Commit f1731986 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

app/widgets/gimpdocked.[ch] moved button-bar API to the GimpDocked

2005-06-05  Sven Neumann  <sven@gimp.org>

	* app/widgets/gimpdocked.[ch]
	* app/widgets/gimpeditor.[ch]: moved button-bar API to the
	GimpDocked interface.

	* app/widgets/gimpcontainereditor.c: implement the new interface
	methods and proxy them to the embedded docked.

	* app/actions/dockable-actions.c
	* app/actions/dockable-commands.c: changed accordingly.
parent 95a57343
2005-06-05 Sven Neumann <sven@gimp.org>
* app/widgets/gimpdocked.[ch]
* app/widgets/gimpeditor.[ch]: moved button-bar API to the
GimpDocked interface.
* app/widgets/gimpcontainereditor.c: implement the new interface
methods and proxy them to the embedded docked.
* app/actions/dockable-actions.c
* app/actions/dockable-commands.c: changed accordingly.
2005-06-04 Manish Singh <yosh@gimp.org>
* libgimp/gimpimagecombobox.h
......
......@@ -34,7 +34,6 @@
#include "widgets/gimpdockable.h"
#include "widgets/gimpdockbook.h"
#include "widgets/gimpdocked.h"
#include "widgets/gimpeditor.h"
#include "widgets/gimphelp-ids.h"
#include "dialogs-actions.h"
......@@ -167,6 +166,7 @@ dockable_actions_update (GimpActionGroup *group,
{
GimpDockable *dockable;
GimpDockbook *dockbook;
GimpDocked *docked;
GimpDialogFactoryEntry *entry;
GimpContainerView *view;
GimpViewType view_type = -1;
......@@ -197,6 +197,8 @@ dockable_actions_update (GimpActionGroup *group,
return;
}
docked = gtk_bin_get_child (GTK_BIN (dockable));
gimp_dialog_factory_from_widget (GTK_WIDGET (dockable), &entry);
if (entry)
......@@ -291,7 +293,7 @@ dockable_actions_update (GimpActionGroup *group,
{
GimpDockedInterface *docked_iface;
docked_iface = GIMP_DOCKED_GET_INTERFACE (GTK_BIN (dockable)->child);
docked_iface = GIMP_DOCKED_GET_INTERFACE (docked);
if (tab_style == GIMP_TAB_STYLE_ICON)
SET_ACTIVE ("dockable-tab-style-icon", TRUE);
......@@ -324,19 +326,9 @@ dockable_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("dockable-view-type-list", list_view_available);
}
if (GIMP_IS_EDITOR (GTK_BIN (dockable)->child))
{
GimpEditor *editor = GIMP_EDITOR (GTK_BIN (dockable)->child);
SET_VISIBLE ("dockable-show-button-bar",
gimp_editor_has_button_bar (editor));
SET_ACTIVE ("dockable-show-button-bar",
gimp_editor_get_show_button_bar (editor));
}
else
{
SET_VISIBLE ("dockable-show-button-bar", FALSE);
}
SET_VISIBLE ("dockable-show-button-bar", gimp_docked_has_button_bar (docked));
SET_ACTIVE ("dockable-show-button-bar",
gimp_docked_get_show_button_bar (docked));
#undef SET_ACTIVE
#undef SET_VISIBLE
......
......@@ -32,7 +32,7 @@
#include "widgets/gimpdock.h"
#include "widgets/gimpdockable.h"
#include "widgets/gimpdockbook.h"
#include "widgets/gimpeditor.h"
#include "widgets/gimpdocked.h"
#include "widgets/gimpsessioninfo.h"
#include "dialogs/dialogs.h"
......@@ -173,12 +173,23 @@ dockable_toggle_view_cmd_callback (GtkAction *action,
preview_size = gimp_container_view_get_preview_size (old_view,
NULL);
new_dockable =
gimp_dialog_factory_dockable_new (dockbook->dock->dialog_factory,
dockbook->dock,
identifier,
preview_size);
if (new_dockable)
{
GimpDocked *old = GIMP_DOCKED (GTK_BIN (dockable)->child);
GimpDocked *new = GIMP_DOCKED (GTK_BIN (new_dockable)->child);
gboolean show;
show = gimp_docked_get_show_button_bar (old);
gimp_docked_set_show_button_bar (new, show);
}
/* Maybe gimp_dialog_factory_dockable_new() returned
* an already existing singleton dockable, so check
* if it already is attached to a dockbook.
......@@ -283,10 +294,9 @@ dockable_show_button_bar_cmd_callback (GtkAction *action,
if (dockable)
{
GtkWidget *child = gtk_bin_get_child (GTK_BIN (dockable));
gboolean show = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
if (GIMP_IS_EDITOR (child))
gimp_editor_set_show_button_bar (GIMP_EDITOR (child),
gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
gimp_docked_set_show_button_bar (GIMP_DOCKED (GTK_BIN (dockable)->child),
show);
}
}
......@@ -69,6 +69,11 @@ static GimpUIManager * gimp_container_editor_get_menu(GimpDocked *docked,
const gchar **ui_path,
gpointer *popup_data);
static gboolean gimp_container_editor_has_button_bar (GimpDocked *docked);
static void gimp_container_editor_set_show_button_bar (GimpDocked *docked,
gboolean show);
static gboolean gimp_container_editor_get_show_button_bar (GimpDocked *docked);
static GtkVBoxClass *parent_class = NULL;
......@@ -130,9 +135,12 @@ gimp_container_editor_init (GimpContainerEditor *view)
static void
gimp_container_editor_docked_iface_init (GimpDockedInterface *docked_iface)
{
docked_iface->get_preview = gimp_container_editor_get_preview;
docked_iface->set_context = gimp_container_editor_set_context;
docked_iface->get_menu = gimp_container_editor_get_menu;
docked_iface->get_preview = gimp_container_editor_get_preview;
docked_iface->set_context = gimp_container_editor_set_context;
docked_iface->get_menu = gimp_container_editor_get_menu;
docked_iface->has_button_bar = gimp_container_editor_has_button_bar;
docked_iface->set_show_button_bar = gimp_container_editor_set_show_button_bar;
docked_iface->get_show_button_bar = gimp_container_editor_get_show_button_bar;
}
gboolean
......@@ -300,3 +308,28 @@ gimp_container_editor_get_menu (GimpDocked *docked,
return gimp_docked_get_menu (GIMP_DOCKED (editor->view), ui_path, popup_data);
}
static gboolean
gimp_container_editor_has_button_bar (GimpDocked *docked)
{
GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (docked);
return gimp_docked_has_button_bar (GIMP_DOCKED (editor->view));
}
static void
gimp_container_editor_set_show_button_bar (GimpDocked *docked,
gboolean show)
{
GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (docked);
gimp_docked_set_show_button_bar (GIMP_DOCKED (editor->view), show);
}
static gboolean
gimp_container_editor_get_show_button_bar (GimpDocked *docked)
{
GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (docked);
return gimp_docked_get_show_button_bar (GIMP_DOCKED (editor->view));
}
......@@ -21,6 +21,8 @@
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "widgets-types.h"
......@@ -29,6 +31,7 @@
#include "core/gimpmarshal.h"
#include "gimpdocked.h"
#include "gimpsessioninfo.h"
enum
......@@ -38,7 +41,12 @@ enum
};
static void gimp_docked_iface_base_init (GimpDockedInterface *docked_iface);
static void gimp_docked_iface_base_init (GimpDockedInterface *docked_iface);
static void gimp_docked_iface_set_aux_info (GimpDocked *docked,
GList *aux_info);
static GList * gimp_docked_iface_get_aux_info (GimpDocked *docked);
static guint docked_signals[LAST_SIGNAL] = { 0 };
......@@ -74,6 +82,12 @@ gimp_docked_iface_base_init (GimpDockedInterface *docked_iface)
{
static gboolean initialized = FALSE;
if (! docked_iface->get_aux_info)
{
docked_iface->get_aux_info = gimp_docked_iface_get_aux_info;
docked_iface->set_aux_info = gimp_docked_iface_set_aux_info;
}
if (! initialized)
{
docked_signals[TITLE_CHANGED] =
......@@ -89,6 +103,41 @@ gimp_docked_iface_base_init (GimpDockedInterface *docked_iface)
}
}
#define AUX_INFO_SHOW_BUTTON_BAR "show-button-bar"
static void
gimp_docked_iface_set_aux_info (GimpDocked *docked,
GList *aux_info)
{
GList *list;
for (list = aux_info; list; list = g_list_next (list))
{
GimpSessionInfoAux *aux = list->data;
if (strcmp (aux->name, AUX_INFO_SHOW_BUTTON_BAR) == 0)
{
gboolean show = g_ascii_strcasecmp (aux->value, "false");
gimp_docked_set_show_button_bar (docked, show);
}
}
}
static GList *
gimp_docked_iface_get_aux_info (GimpDocked *docked)
{
if (gimp_docked_has_button_bar (docked) &&
! gimp_docked_get_show_button_bar (docked))
{
return g_list_append (NULL,
gimp_session_info_aux_new (AUX_INFO_SHOW_BUTTON_BAR,
"false"));
}
return NULL;
}
void
gimp_docked_title_changed (GimpDocked *docked)
{
......@@ -191,3 +240,47 @@ gimp_docked_set_context (GimpDocked *docked,
if (docked_iface->set_context)
docked_iface->set_context (docked, context);
}
gboolean
gimp_docked_has_button_bar (GimpDocked *docked)
{
GimpDockedInterface *docked_iface;
g_return_val_if_fail (GIMP_IS_DOCKED (docked), FALSE);
docked_iface = GIMP_DOCKED_GET_INTERFACE (docked);
if (docked_iface->has_button_bar)
return docked_iface->has_button_bar (docked);
return FALSE;
}
void
gimp_docked_set_show_button_bar (GimpDocked *docked,
gboolean show)
{
GimpDockedInterface *docked_iface;
g_return_if_fail (GIMP_IS_DOCKED (docked));
docked_iface = GIMP_DOCKED_GET_INTERFACE (docked);
if (docked_iface->set_show_button_bar)
docked_iface->set_show_button_bar (docked, show ? TRUE : FALSE);
}
gboolean
gimp_docked_get_show_button_bar (GimpDocked *docked)
{
GimpDockedInterface *docked_iface;
g_return_val_if_fail (GIMP_IS_DOCKED (docked), FALSE);
docked_iface = GIMP_DOCKED_GET_INTERFACE (docked);
if (docked_iface->get_show_button_bar)
return docked_iface->get_show_button_bar (docked);
return FALSE;
}
......@@ -36,44 +36,54 @@ struct _GimpDockedInterface
GTypeInterface base_iface;
/* signals */
void (* title_changed) (GimpDocked *docked);
void (* title_changed) (GimpDocked *docked);
/* virtual functions */
void (* set_aux_info) (GimpDocked *docked,
GList *aux_info);
GList * (* get_aux_info) (GimpDocked *docked);
GtkWidget * (* get_preview) (GimpDocked *docked,
GimpContext *context,
GtkIconSize size);
GimpUIManager * (* get_menu) (GimpDocked *docked,
const gchar **ui_path,
gpointer *popup_data);
gchar * (* get_title) (GimpDocked *docked);
void (* set_context) (GimpDocked *docked,
GimpContext *context);
void (* set_aux_info) (GimpDocked *docked,
GList *aux_info);
GList * (* get_aux_info) (GimpDocked *docked);
GtkWidget * (* get_preview) (GimpDocked *docked,
GimpContext *context,
GtkIconSize size);
GimpUIManager * (* get_menu) (GimpDocked *docked,
const gchar **ui_path,
gpointer *popup_data);
gchar * (* get_title) (GimpDocked *docked);
void (* set_context) (GimpDocked *docked,
GimpContext *context);
gboolean (* has_button_bar) (GimpDocked *docked);
void (* set_show_button_bar) (GimpDocked *docked,
gboolean show);
gboolean (* get_show_button_bar) (GimpDocked *docked);
};
GType gimp_docked_interface_get_type (void) G_GNUC_CONST;
GType gimp_docked_interface_get_type (void) G_GNUC_CONST;
void gimp_docked_title_changed (GimpDocked *docked);
void gimp_docked_title_changed (GimpDocked *docked);
void gimp_docked_set_aux_info (GimpDocked *docked,
GList *aux_info);
GList * gimp_docked_get_aux_info (GimpDocked *docked);
void gimp_docked_set_aux_info (GimpDocked *docked,
GList *aux_info);
GList * gimp_docked_get_aux_info (GimpDocked *docked);
GtkWidget * gimp_docked_get_preview (GimpDocked *docked,
GimpContext *context,
GtkIconSize size);
GimpUIManager * gimp_docked_get_menu (GimpDocked *docked,
const gchar **ui_path,
gpointer *popup_data);
gchar * gimp_docked_get_title (GimpDocked *docked);
GtkWidget * gimp_docked_get_preview (GimpDocked *docked,
GimpContext *context,
GtkIconSize size);
GimpUIManager * gimp_docked_get_menu (GimpDocked *docked,
const gchar **ui_path,
gpointer *popup_data);
gchar * gimp_docked_get_title (GimpDocked *docked);
void gimp_docked_set_context (GimpDocked *docked,
GimpContext *context);
void gimp_docked_set_context (GimpDocked *docked,
GimpContext *context);
gboolean gimp_docked_has_button_bar (GimpDocked *docked);
void gimp_docked_set_show_button_bar (GimpDocked *docked,
gboolean show);
gboolean gimp_docked_get_show_button_bar (GimpDocked *docked);
#endif /* __GIMP_DOCKED_H__ */
......@@ -21,8 +21,6 @@
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
......@@ -33,7 +31,6 @@
#include "gimpeditor.h"
#include "gimpdnd.h"
#include "gimpmenufactory.h"
#include "gimpsessioninfo.h"
#include "gimpuimanager.h"
#include "gimpwidgets-utils.h"
......@@ -53,8 +50,7 @@ enum
PROP_UI_PATH,
PROP_POPUP_DATA,
PROP_SHOW_NAME,
PROP_NAME,
PROP_SHOW_BUTTON_BAR
PROP_NAME
};
......@@ -77,15 +73,15 @@ static void gimp_editor_destroy (GtkObject *object);
static void gimp_editor_style_set (GtkWidget *widget,
GtkStyle *prev_style);
static void gimp_editor_set_aux_info (GimpDocked *docked,
GList *aux_info);
static GList * gimp_editor_get_aux_info (GimpDocked *docked);
static GimpUIManager * gimp_editor_get_menu (GimpDocked *docked,
const gchar **ui_path,
gpointer *popup_data);
static GimpUIManager * gimp_editor_get_menu (GimpDocked *docked,
const gchar **ui_path,
gpointer *popup_data);
static gboolean gimp_editor_has_button_bar (GimpDocked *docked);
static void gimp_editor_set_show_button_bar (GimpDocked *docked,
gboolean show);
static gboolean gimp_editor_get_show_button_bar (GimpDocked *docked);
static GtkIconSize gimp_editor_ensure_button_box (GimpEditor *editor);
static GtkIconSize gimp_editor_ensure_button_box (GimpEditor *editor);
static GtkVBoxClass *parent_class = NULL;
......@@ -186,13 +182,6 @@ gimp_editor_class_init (GimpEditorClass *klass)
G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, PROP_SHOW_BUTTON_BAR,
g_param_spec_boolean ("show-button-bar",
NULL, NULL,
TRUE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("content_spacing",
NULL, NULL,
......@@ -226,6 +215,7 @@ gimp_editor_init (GimpEditor *editor)
editor->ui_path = NULL;
editor->popup_data = editor;
editor->button_box = NULL;
editor->show_button_bar = TRUE;
editor->name_label = g_object_new (GTK_TYPE_LABEL,
"xalign", 0.0,
......@@ -243,9 +233,10 @@ gimp_editor_docked_iface_init (GimpDockedInterface *docked_iface)
{
parent_docked_iface = g_type_interface_peek_parent (docked_iface);
docked_iface->set_aux_info = gimp_editor_set_aux_info;
docked_iface->get_aux_info = gimp_editor_get_aux_info;
docked_iface->get_menu = gimp_editor_get_menu;
docked_iface->get_menu = gimp_editor_get_menu;
docked_iface->has_button_bar = gimp_editor_has_button_bar;
docked_iface->set_show_button_bar = gimp_editor_set_show_button_bar;
docked_iface->get_show_button_bar = gimp_editor_get_show_button_bar;
}
static GObject *
......@@ -303,9 +294,6 @@ gimp_editor_set_property (GObject *object,
case PROP_NAME:
gimp_editor_set_name (editor, g_value_get_string (value));
break;
case PROP_SHOW_BUTTON_BAR:
gimp_editor_set_show_button_bar (editor, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
......@@ -337,9 +325,6 @@ gimp_editor_get_property (GObject *object,
case PROP_SHOW_NAME:
g_object_get_property (G_OBJECT (editor->name_label), "visible", value);
break;
case PROP_SHOW_BUTTON_BAR:
g_value_set_boolean (value, editor->show_button_bar);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
......@@ -396,72 +381,60 @@ gimp_editor_style_set (GtkWidget *widget,
gimp_editor_set_box_style (editor, GTK_BOX (editor->button_box));
}
#define AUX_INFO_SHOW_BUTTON_BAR "show-button-bar"
static void
gimp_editor_set_aux_info (GimpDocked *docked,
GList *aux_info)
static GimpUIManager *
gimp_editor_get_menu (GimpDocked *docked,
const gchar **ui_path,
gpointer *popup_data)
{
GList *list;
GimpEditor *editor = GIMP_EDITOR (docked);
if (parent_docked_iface && parent_docked_iface->set_aux_info)
parent_docked_iface->set_aux_info (docked, aux_info);
*ui_path = editor->ui_path;
*popup_data = editor->popup_data;
for (list = aux_info; list; list = g_list_next (list))
{
GimpSessionInfoAux *aux = list->data;
return editor->ui_manager;
}
if (strcmp (aux->name, AUX_INFO_SHOW_BUTTON_BAR) == 0)
{
gboolean show = g_ascii_strcasecmp (aux->value, "false");
gimp_editor_set_show_button_bar (GIMP_EDITOR (docked), show);
}
}
static gboolean
gimp_editor_has_button_bar (GimpDocked *docked)
{
GimpEditor *editor = GIMP_EDITOR (docked);
return editor->button_box != NULL;
}
static GList *
gimp_editor_get_aux_info (GimpDocked *docked)
static void
gimp_editor_set_show_button_bar (GimpDocked *docked,
gboolean show)
{
GimpEditor *editor = GIMP_EDITOR (docked);
GList *aux_info = NULL;
if (parent_docked_iface && parent_docked_iface->set_aux_info)
aux_info = parent_docked_iface->get_aux_info (docked);
GimpEditor *editor = GIMP_EDITOR (docked);
if (! editor->show_button_bar)
if (show != editor->show_button_bar)
{
aux_info =
g_list_append (aux_info,
gimp_session_info_aux_new (AUX_INFO_SHOW_BUTTON_BAR,
"false"));
}
editor->show_button_bar = show;
return aux_info;
if (editor->button_box)
{
if (show)
gtk_widget_show (editor->button_box);
else
gtk_widget_hide (editor->button_box);
}
}
}
static GimpUIManager *
gimp_editor_get_menu (GimpDocked *docked,
const gchar **ui_path,
gpointer *popup_data)
static gboolean
gimp_editor_get_show_button_bar (GimpDocked *docked)
{
GimpEditor *editor = GIMP_EDITOR (docked);
*ui_path = editor->ui_path;
*popup_data = editor->popup_data;
return editor->ui_manager;
return editor->show_button_bar;
}
GtkWidget *
gimp_editor_new (void)
{
GimpEditor *editor;
editor = g_object_new (GIMP_TYPE_EDITOR, NULL);
return GTK_WIDGET (editor);
return g_object_new (GIMP_TYPE_EDITOR, NULL);
}
void
......@@ -831,46 +804,6 @@ gimp_editor_set_box_style (GimpEditor *editor,
g_list_free (children);
}
gboolean
gimp_editor_has_button_bar (GimpEditor *editor)
{
g_return_val_if_fail (GIMP_IS_EDITOR (editor), FALSE);
return editor->button_box != NULL;
}
void
gimp_editor_set_show_button_bar (GimpEditor *editor,
gboolean show)
{
g_return_if_fail (GIMP_IS_EDITOR (editor));
show = show ? TRUE : FALSE;
if (show != editor->show_button_bar)
{
editor->show_button_bar = show;
if (editor->button_box)
{
if (show)
gtk_widget_show (editor->button_box);
else
gtk_widget_hide (editor->button_box);
}
g_object_notify (G_OBJECT (editor), "show-button-bar");
}
}
gboolean
gimp_editor_get_show_button_bar (GimpEditor *editor)
{
g_return_val_if_fail (GIMP_IS_EDITOR (editor), FALSE);
return editor->show_button_bar;
}
/* private functions */
......
......@@ -96,10 +96,5 @@ void gimp_editor_set_name (GimpEditor *editor,
void gimp_editor_set_box_style (GimpEditor *editor,
GtkBox *box);
gboolean gimp_editor_has_button_bar (GimpEditor *editor);
void gimp_editor_set_show_button_bar (GimpEditor *editor,
gboolean show);
gboolean gimp_editor_get_show_button_bar (GimpEditor *editor);
#endif /* __GIMP_EDITOR_H__ */
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