Commit 5412fac0 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

app/actions/dockable-actions.c app/actions/dockable-commands.[ch]

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

	* app/actions/dockable-actions.c
	* app/actions/dockable-commands.[ch]
	* app/widgets/gimpeditor.[ch]
	* app/widgets/gimphelp-ids.h
	* menus/dockable-menu.xml.in: allow to show/hide the button-bar in
	GimpEditor. Should be merged into the GimpDocked interface.
parent 7ce0c7a9
2005-06-04 Sven Neumann <sven@gimp.org>
* app/actions/dockable-actions.c
* app/actions/dockable-commands.[ch]
* app/widgets/gimpeditor.[ch]
* app/widgets/gimphelp-ids.h
* menus/dockable-menu.xml.in: allow to show/hide the button-bar in
GimpEditor. Should be merged into the GimpDocked interface.
2005-06-04 Manish Singh <yosh@gimp.org>
* plug-ins/helpbrowser/dialog.c: define _O_BINARY ourselves if
......
......@@ -34,6 +34,7 @@
#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"
......@@ -49,10 +50,10 @@ static GimpActionEntry dockable_actions[] =
N_("Dialogs Menu"), NULL, NULL, NULL,
GIMP_HELP_DOCK },
{ "dockable-menu", GTK_STOCK_MISSING_IMAGE, "" },
{ "dockable-add-tab-menu", NULL, N_("_Add Tab") },
{ "dockable-preview-size-menu", NULL, N_("_Preview Size") },
{ "dockable-tab-style-menu", NULL, N_("_Tab Style") },
{ "dockable-menu", GTK_STOCK_MISSING_IMAGE, "" },
{ "dockable-add-tab-menu", NULL, N_("_Add Tab") },
{ "dockable-preview-size-menu", NULL, N_("_Preview Size") },
{ "dockable-tab-style-menu", NULL, N_("_Tab Style") },
{ "dockable-close-tab", GTK_STOCK_CLOSE,
N_("_Close Tab"), "", NULL,
......@@ -101,6 +102,16 @@ static GimpRadioActionEntry dockable_tab_style_actions[] =
#undef PREVIEW_SIZE
#undef TAB_STYLE
static GimpToggleActionEntry dockable_toggle_actions[] =
{
{ "dockable-show-button-bar", NULL,
N_("_Show Button Bar"), NULL, NULL,
G_CALLBACK (dockable_show_button_bar_cmd_callback),
TRUE,
GIMP_HELP_DOCK_SHOW_BUTTON_BAR }
};
static GimpRadioActionEntry dockable_view_type_actions[] =
{
{ "dockable-view-type-list", NULL,
......@@ -122,6 +133,10 @@ dockable_actions_setup (GimpActionGroup *group)
dockable_actions,
G_N_ELEMENTS (dockable_actions));
gimp_action_group_add_toggle_actions (group,
dockable_toggle_actions,
G_N_ELEMENTS (dockable_toggle_actions));
gimp_action_group_add_string_actions (group,
dialogs_dockable_actions,
n_dialogs_dockable_actions,
......@@ -309,6 +324,20 @@ 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);
}
#undef SET_ACTIVE
#undef SET_VISIBLE
#undef SET_SENSITIVE
......
......@@ -32,6 +32,7 @@
#include "widgets/gimpdock.h"
#include "widgets/gimpdockable.h"
#include "widgets/gimpdockbook.h"
#include "widgets/gimpeditor.h"
#include "widgets/gimpsessioninfo.h"
#include "dialogs/dialogs.h"
......@@ -266,3 +267,26 @@ dockable_tab_style_cmd_callback (GtkAction *action,
tab_widget);
}
}
void
dockable_show_button_bar_cmd_callback (GtkAction *action,
gpointer data)
{
GimpDockbook *dockbook = GIMP_DOCKBOOK (data);
GimpDockable *dockable;
gint page_num;
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
dockable = (GimpDockable *)
gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
if (dockable)
{
GtkWidget *child = gtk_bin_get_child (GTK_BIN (dockable));
if (GIMP_IS_EDITOR (child))
gimp_editor_set_show_button_bar (GIMP_EDITOR (child),
gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
}
}
......@@ -20,23 +20,25 @@
#define __DOCKABLE_COMMANDS_H__
void dockable_add_tab_cmd_callback (GtkAction *action,
const gchar *value,
gpointer data);
void dockable_close_tab_cmd_callback (GtkAction *action,
gpointer data);
void dockable_detach_tab_cmd_callback (GtkAction *action,
gpointer data);
void dockable_add_tab_cmd_callback (GtkAction *action,
const gchar *value,
gpointer data);
void dockable_close_tab_cmd_callback (GtkAction *action,
gpointer data);
void dockable_detach_tab_cmd_callback (GtkAction *action,
gpointer data);
void dockable_toggle_view_cmd_callback (GtkAction *action,
GtkAction *current,
gpointer data);
void dockable_preview_size_cmd_callback (GtkAction *action,
GtkAction *current,
gpointer data);
void dockable_tab_style_cmd_callback (GtkAction *action,
GtkAction *current,
gpointer data);
void dockable_toggle_view_cmd_callback (GtkAction *action,
GtkAction *current,
gpointer data);
void dockable_preview_size_cmd_callback (GtkAction *action,
GtkAction *current,
gpointer data);
void dockable_tab_style_cmd_callback (GtkAction *action,
GtkAction *current,
gpointer data);
void dockable_show_button_bar_cmd_callback (GtkAction *action,
gpointer data);
#endif /* __DOCKABLE_COMMANDS_H__ */
......@@ -21,6 +21,8 @@
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
......@@ -31,6 +33,7 @@
#include "gimpeditor.h"
#include "gimpdnd.h"
#include "gimpmenufactory.h"
#include "gimpsessioninfo.h"
#include "gimpuimanager.h"
#include "gimpwidgets-utils.h"
......@@ -50,7 +53,8 @@ enum
PROP_UI_PATH,
PROP_POPUP_DATA,
PROP_SHOW_NAME,
PROP_NAME
PROP_NAME,
PROP_SHOW_BUTTON_BAR
};
......@@ -73,6 +77,10 @@ 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);
......@@ -80,7 +88,8 @@ static GimpUIManager * gimp_editor_get_menu (GimpDocked *docked,
static GtkIconSize gimp_editor_ensure_button_box (GimpEditor *editor);
static GtkVBoxClass *parent_class = NULL;
static GtkVBoxClass *parent_class = NULL;
static GimpDockedInterface *parent_docked_iface = NULL;
GType
......@@ -177,6 +186,13 @@ 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,
......@@ -225,7 +241,11 @@ gimp_editor_init (GimpEditor *editor)
static void
gimp_editor_docked_iface_init (GimpDockedInterface *docked_iface)
{
docked_iface->get_menu = gimp_editor_get_menu;
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;
}
static GObject *
......@@ -283,6 +303,9 @@ 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;
......@@ -314,6 +337,9 @@ 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;
......@@ -370,6 +396,51 @@ 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)
{
GList *list;
if (parent_docked_iface && parent_docked_iface->set_aux_info)
parent_docked_iface->set_aux_info (docked, aux_info);
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_editor_set_show_button_bar (GIMP_EDITOR (docked), show);
}
}
}
static GList *
gimp_editor_get_aux_info (GimpDocked *docked)
{
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);
if (! editor->show_button_bar)
{
aux_info =
g_list_append (aux_info,
gimp_session_info_aux_new (AUX_INFO_SHOW_BUTTON_BAR,
"false"));
}
return aux_info;
}
static GimpUIManager *
gimp_editor_get_menu (GimpDocked *docked,
const gchar **ui_path,
......@@ -760,6 +831,46 @@ 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 */
......@@ -779,7 +890,9 @@ gimp_editor_ensure_button_box (GimpEditor *editor)
editor->button_box = gtk_hbox_new (TRUE, button_spacing);
gtk_box_pack_end (GTK_BOX (editor), editor->button_box, FALSE, FALSE, 0);
gtk_box_reorder_child (GTK_BOX (editor), editor->button_box, 0);
gtk_widget_show (editor->button_box);
if (editor->show_button_bar)
gtk_widget_show (editor->button_box);
}
return button_icon_size;
......
......@@ -46,6 +46,7 @@ struct _GimpEditor
gchar *ui_path;
gpointer popup_data;
gboolean show_button_bar;
GtkWidget *name_label;
GtkWidget *button_box;
};
......@@ -87,13 +88,18 @@ GtkWidget * gimp_editor_add_action_button (GimpEditor *editor,
const gchar *action_name,
...);
void gimp_editor_set_show_name (GimpEditor *editor,
gboolean show);
void gimp_editor_set_name (GimpEditor *editor,
const gchar *name);
void gimp_editor_set_show_name (GimpEditor *editor,
gboolean show);
void gimp_editor_set_name (GimpEditor *editor,
const gchar *name);
void gimp_editor_set_box_style (GimpEditor *editor,
GtkBox *box);
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__ */
......@@ -424,6 +424,7 @@
#define GIMP_HELP_DOCK_TAB_STYLE "gimp-dock-tab-style"
#define GIMP_HELP_DOCK_VIEW_AS_LIST "gimp-dock-view-as-list"
#define GIMP_HELP_DOCK_VIEW_AS_GRID "gimp-dock-view-as-grid"
#define GIMP_HELP_DOCK_SHOW_BUTTON_BAR "gimp-dock-show-button-bar"
#define GIMP_HELP_ABOUT_DIALOG "gimp-about-dialog"
#define GIMP_HELP_COLOR_DIALOG "gimp-color-dialog"
......
......@@ -29,6 +29,7 @@
</menu>
<menuitem action="dockable-view-type-list" />
<menuitem action="dockable-view-type-grid" />
<menuitem action="dockable-show-button-bar"/>
<separator />
<menuitem action="dock-show-image-menu" />
<menuitem action="dock-auto-follow-active" />
......
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