/* * Sets the properties of the widget. This is used for both applying the * properties changed in the property editor, and also for loading. */ static void gb_handle_box_set_properties(GtkWidget *widget, GbWidgetSetArgData *data) { gchar *shadow, *position, *snap_edge; gint i; shadow = gb_widget_input_choice (data, Shadow); if (data->apply) { for (i = 0; i < sizeof (GbShadowValues) / sizeof (GbShadowValues[0]); i++) { if (!strcmp (shadow, GbShadowChoices[i]) || !strcmp (shadow, GbShadowSymbols[i])) { gtk_handle_box_set_shadow_type (GTK_HANDLE_BOX (widget), GbShadowValues[i]); break; } } } position = gb_widget_input_choice (data, Position); if (data->apply) { for (i = 0; i < sizeof (GbPositionValues) / sizeof (GbPositionValues[0]); i++) { if (!strcmp (position, GbPositionChoices[i]) || !strcmp (position, GbPositionSymbols[i])) { gtk_handle_box_set_handle_position (GTK_HANDLE_BOX (widget), GbPositionValues[i]); break; } } } snap_edge = gb_widget_input_choice (data, SnapEdge); if (data->apply) { for (i = 0; i < sizeof (GbPositionValues) / sizeof (GbPositionValues[0]); i++) { if (!strcmp (snap_edge, GbPositionChoices[i]) || !strcmp (snap_edge, GbPositionSymbols[i])) { gtk_handle_box_set_snap_edge (GTK_HANDLE_BOX (widget), GbPositionValues[i]); break; } } } }
/* * Creates a new GtkWidget of class GtkHandleBox, performing any specialized * initialization needed for the widget to work correctly in this environment. * If a dialog box is used to initialize the widget, return NULL from this * function, and call data->callback with your new widget when it is done. * If the widget needs a special destroy handler, add a signal here. */ GtkWidget * gb_handle_box_new (GbWidgetNewData * data) { GtkWidget *new_widget = gtk_handle_box_new (); /* We set the snap edge to top, which matches the default handle position, since we don't support the default value of -1. */ gtk_handle_box_set_snap_edge (GTK_HANDLE_BOX (new_widget), GTK_POS_TOP); if (data->action != GB_LOADING) gtk_container_add (GTK_CONTAINER (new_widget), editor_new_placeholder ()); return new_widget; }
/** * cact_main_toolbar_activate: * @window: this #CactMainWindow. * @toolbar_id: the id of the activated toolbar. * @ui_manager: the #GtkUIManager. * @is_active: whether this toolbar is activated or not. * * Activate or desactivate the toolbar. */ void cact_main_toolbar_activate( CactMainWindow *window, int toolbar_id, GtkUIManager *ui_manager, gboolean is_active ) { static const gchar *thisfn = "cact_main_toolbar_activate"; ToolbarProps *props; GtkWidget *toolbar, *hbox, *handle; gulong attach_id, detach_id; props = get_toolbar_properties( toolbar_id ); if( !props ){ return; } toolbar = gtk_ui_manager_get_widget( ui_manager, props->ui_path ); g_debug( "%s: toolbar=%p, path=%s, ref_count=%d", thisfn, ( void * ) toolbar, props->ui_path, G_OBJECT( toolbar )->ref_count ); hbox = base_window_get_widget( BASE_WINDOW( window ), "ToolbarHBox" ); if( is_active ){ handle = gtk_handle_box_new(); gtk_handle_box_set_snap_edge( GTK_HANDLE_BOX( handle ), GTK_POS_LEFT ); g_object_set_data( G_OBJECT( toolbar ), "cact-main-toolbar-handle", handle ); attach_id = g_signal_connect( handle, "child-attached", (GCallback ) on_attach_toolbar, window ); g_object_set_data( G_OBJECT( handle ), "cact-handle-attach-id", ( gpointer ) attach_id ); detach_id = g_signal_connect( handle, "child-detached", (GCallback ) on_detach_toolbar, window ); g_object_set_data( G_OBJECT( handle ), "cact-handle-detach-id", ( gpointer ) detach_id ); g_object_weak_ref( G_OBJECT( handle ), ( GWeakNotify ) on_handle_finalize, NULL ); gtk_container_add( GTK_CONTAINER( handle ), toolbar ); gtk_container_add( GTK_CONTAINER( hbox ), handle ); reorder_toolbars( hbox, toolbar_id, handle ); gtk_widget_show_all( handle ); } else { handle = ( GtkWidget * ) g_object_get_data( G_OBJECT( toolbar ), "cact-main-toolbar-handle" ); detach_id = ( gulong ) g_object_get_data( G_OBJECT( handle ), "cact-handle-detach-id" ); g_signal_handler_disconnect( handle, detach_id ); attach_id = ( gulong ) g_object_get_data( G_OBJECT( handle ), "cact-handle-attach-id" ); g_signal_handler_disconnect( handle, attach_id ); gtk_container_remove( GTK_CONTAINER( handle ), toolbar ); gtk_container_remove( GTK_CONTAINER( hbox ), handle ); } na_settings_set_boolean( props->prefs_key, is_active ); }