static void
xviewer_properties_dialog_set_property (GObject      *object,
				    guint         prop_id,
				    const GValue *value,
				    GParamSpec   *pspec)
{
	XviewerPropertiesDialog *prop_dlg = XVIEWER_PROPERTIES_DIALOG (object);

	switch (prop_id) {
		case PROP_THUMBVIEW:
			prop_dlg->priv->thumbview = g_value_get_object (value);
			break;
		case PROP_NETBOOK_MODE:
			xviewer_properties_dialog_set_netbook_mode (prop_dlg,
						   g_value_get_boolean (value));
			break;
		case PROP_NEXT_ACTION:
			gtk_activatable_set_related_action (GTK_ACTIVATABLE (prop_dlg->priv->next_button),
							    g_value_get_object(value));
			gtk_button_set_always_show_image(GTK_BUTTON(prop_dlg->priv->next_button), TRUE);
			break;
		case PROP_PREV_ACTION:
			gtk_activatable_set_related_action (GTK_ACTIVATABLE (prop_dlg->priv->previous_button),
							    g_value_get_object(value));
			gtk_button_set_always_show_image(GTK_BUTTON(prop_dlg->priv->previous_button), TRUE);
			break;
		default:
			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id,
							   pspec);
			break;
	}
}
Esempio n. 2
0
static GtkWidget *
create_menu_item (GtkAction *action)
{
  NemoWidgetAction *widget_action;
  GType menu_item_type;
  GtkWidget *w, *ret;
  gint slot;

  widget_action = NEMO_WIDGET_ACTION (action);
  menu_item_type = GTK_ACTION_GET_CLASS (action)->menu_item_type;

  if (!widget_action->a_used) {
    w = widget_action->widget_a;
    widget_action->a_used = TRUE;
    slot = ACTION_SLOT_A;
  } else if (!widget_action->b_used) {
    w = widget_action->widget_b;
    widget_action->b_used = TRUE;
    slot = ACTION_SLOT_B;
  } else
    return NULL;

  ret = g_object_new (menu_item_type,
                      "child-widget", w,
                      "action-slot", slot,
                      NULL);

  gtk_activatable_set_related_action (GTK_ACTIVATABLE (ret), action);

  return ret;
}
Esempio n. 3
0
static GtkWidget *
toolbar_create_toolbutton (NemoToolbar *self,
                gboolean create_toggle,
                const gchar *name)
{
    GtkWidget *button;
    GtkWidget *image;
    GtkAction *action;

    if (create_toggle)
    {
        button = gtk_toggle_button_new ();
    } else {
        button = gtk_button_new ();
    }

    image = gtk_image_new ();

    gtk_button_set_image (GTK_BUTTON (button), image);
    action = gtk_action_group_get_action (self->priv->action_group, name);
    gtk_activatable_set_related_action (GTK_ACTIVATABLE (button), action);
    gtk_button_set_label (GTK_BUTTON (button), NULL);
    gtk_widget_set_tooltip_text (button, gtk_action_get_tooltip (action));

    return button;
}
Esempio n. 4
0
GtkWidget *
vnr_properties_dialog_new (VnrWindow *vnr_win, GtkAction *next_action, GtkAction *prev_action)
{
    VnrPropertiesDialog *dialog;

    dialog = g_object_new (VNR_TYPE_PROPERTIES_DIALOG, NULL);

    dialog->thumbnail = NULL;
    dialog->vnr_win = vnr_win;

	gtk_activatable_set_related_action (GTK_ACTIVATABLE(dialog->next_button), next_action);

    gtk_activatable_set_related_action (GTK_ACTIVATABLE(dialog->prev_button), prev_action);

    gtk_button_set_label (GTK_BUTTON(dialog->next_button), _("_Next"));
    gtk_button_set_label (GTK_BUTTON(dialog->prev_button), _("_Previous"));
    gtk_widget_grab_focus (dialog->close_button);

    return (GtkWidget *) dialog;
}
Esempio n. 5
0
/**
 * gtk_action_create_tool_item:
 * @action: the action object
 *
 * Creates a toolbar item widget that proxies for the given action.
 *
 * Returns: (transfer none): a toolbar item connected to the action.
 *
 * Since: 2.4
 */
GtkWidget *
gtk_action_create_tool_item (GtkAction *action)
{
  GtkWidget *button;

  g_return_val_if_fail (GTK_IS_ACTION (action), NULL);

  button = GTK_ACTION_GET_CLASS (action)->create_tool_item (action);

  gtk_activatable_set_use_action_appearance (GTK_ACTIVATABLE (button), TRUE);
  gtk_activatable_set_related_action (GTK_ACTIVATABLE (button), action);

  return button;
}
Esempio n. 6
0
/**
 * gtk_action_create_menu_item:
 * @action: the action object
 *
 * Creates a menu item widget that proxies for the given action.
 *
 * Returns: (transfer none): a menu item connected to the action.
 *
 * Since: 2.4
 */
GtkWidget *
gtk_action_create_menu_item (GtkAction *action)
{
  GtkWidget *menu_item;

  g_return_val_if_fail (GTK_IS_ACTION (action), NULL);

  menu_item = GTK_ACTION_GET_CLASS (action)->create_menu_item (action);

  gtk_activatable_set_use_action_appearance (GTK_ACTIVATABLE (menu_item), TRUE);
  gtk_activatable_set_related_action (GTK_ACTIVATABLE (menu_item), action);

  return menu_item;
}
Esempio n. 7
0
static GtkWidget *
toolbar_create_toolbutton (NautilusToolbar *self,
			   gboolean create_menu,
			   gboolean create_toggle,
			   const gchar *name,
			   const gchar *tooltip)
{
	GtkWidget *button, *image;
	GtkActionGroup *action_group;
	GtkAction *action;

	action_group = nautilus_window_get_main_action_group (self->priv->window);

	if (create_menu) {
		button = gtk_menu_button_new ();
	} else if (create_toggle) {
		button = gtk_toggle_button_new ();
	} else {
		button = gtk_button_new ();
	}

	image = gtk_image_new ();

	gtk_button_set_image (GTK_BUTTON (button), image);

	if (create_menu) {
		gtk_image_set_from_icon_name (GTK_IMAGE (image), name,
					      GTK_ICON_SIZE_MENU);
		gtk_widget_set_tooltip_text (button, tooltip);
	} else {
		action = gtk_action_group_get_action (action_group, name);
		gtk_activatable_set_related_action (GTK_ACTIVATABLE (button), action);
		gtk_button_set_label (GTK_BUTTON (button), NULL);
		gtk_widget_set_tooltip_text (button, gtk_action_get_tooltip (action));
	}

	return button;
}
GtkWidget* create_tool_item( GtkAction* action )
{
    GtkWidget* item = 0;

    if ( IS_EGE_SELECT_ONE_ACTION(action) && EGE_SELECT_ONE_ACTION(action)->private_data->model )
    {
        EgeSelectOneAction* act = EGE_SELECT_ONE_ACTION(action);
        item = GTK_WIDGET( gtk_tool_item_new() );

        if ( act->private_data->appearanceMode == APPEARANCE_FULL ) {
#if GTK_CHECK_VERSION(3,0,0)
            GtkWidget* holder = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
            gtk_box_set_homogeneous(GTK_BOX(holder), FALSE);
#else
            GtkWidget* holder = gtk_hbox_new( FALSE, 0 );
#endif

            GtkRadioAction* ract = 0;
            GSList* group = 0;
            GtkTreeIter iter;
            gboolean valid = FALSE;
            gint index = 0;

            {
                gchar*  sss = 0;
                g_object_get( G_OBJECT(action), "short_label", &sss, NULL );
                // If short_label not defined, g_object_get will return label.
                // This hack allows a label to be used with a drop-down menu when
                // no label is used with a set of icons that are self-explanatory.
                if (sss && strcmp( sss, "NotUsed" ) != 0 ) {
                    GtkWidget* lbl = gtk_label_new(sss);
                    gtk_box_pack_start( GTK_BOX(holder), lbl, FALSE, FALSE, 4 );
                }
                g_free( sss );
                sss = 0;
            }

            valid = gtk_tree_model_get_iter_first( act->private_data->model, &iter );
            while ( valid ) {
                gchar* str = 0;
                gchar* tip = 0;
                gchar* iconId = 0;
                gboolean sens = true;
                /*
                gint size = 0;
                */
                gtk_tree_model_get( act->private_data->model, &iter,
                                    act->private_data->labelColumn, &str,
                                    -1 );
                if ( act->private_data->iconColumn >= 0 ) {
                    gtk_tree_model_get( act->private_data->model, &iter,
                                        act->private_data->iconColumn, &iconId,
                                        -1 );
                }
                if ( act->private_data->tooltipColumn >= 0 ) {
                    gtk_tree_model_get( act->private_data->model, &iter,
                                        act->private_data->tooltipColumn, &tip,
                                        -1 );
                }
                if ( act->private_data->sensitiveColumn >= 0 ) {
                    gtk_tree_model_get( act->private_data->model, &iter,
                                        act->private_data->sensitiveColumn, &sens,
                                        -1 );
                }

                if ( act->private_data->radioActionType ) {
                    void* obj = g_object_new( act->private_data->radioActionType,
                                              "name", "Name 1",
                                              "label", str,
                                              "tooltip", tip,
                                              "value", index,
                                              /*
                                              "iconId", iconId,
                                              "iconSize", size,
                                              */
                                              NULL );
                    if ( iconId ) {
                        g_object_set( G_OBJECT(obj), act->private_data->iconProperty, iconId, NULL );
                    }

                    if ( act->private_data->iconProperty ) {
                        /* TODO get this string to be set instead of hardcoded */
                        if ( act->private_data->iconSize >= 0 ) {
                            g_object_set( G_OBJECT(obj), "iconSize", act->private_data->iconSize, NULL );
                        }
                    }

                    ract = GTK_RADIO_ACTION(obj);
                } else {
                    ract = gtk_radio_action_new( "Name 1", str, tip, iconId, index );
                }

                if ( act->private_data->sensitiveColumn >= 0 ) {
                    gtk_action_set_sensitive( GTK_ACTION(ract), sens );
                }

                gtk_radio_action_set_group( ract, group );
                group = gtk_radio_action_get_group( ract );

                if ( index == act->private_data->active ) {
                    gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(ract), TRUE );
                }
                g_signal_connect( G_OBJECT(ract), "changed", G_CALLBACK( proxy_action_chagned_cb ), act );

                GtkWidget* sub = gtk_action_create_tool_item( GTK_ACTION(ract) );
                gtk_activatable_set_related_action( GTK_ACTIVATABLE (sub), GTK_ACTION(ract) );
                gtk_tool_item_set_tooltip_text( GTK_TOOL_ITEM(sub), tip );

                gtk_box_pack_start( GTK_BOX(holder), sub, FALSE, FALSE, 0 );

                g_free( str );
                g_free( tip );
                g_free( iconId );

                index++;
                valid = gtk_tree_model_iter_next( act->private_data->model, &iter );
            }

            g_object_set_data( G_OBJECT(holder), "ege-proxy_action-group", group );

            gtk_container_add( GTK_CONTAINER(item), holder );
        } else {
#if GTK_CHECK_VERSION(3,0,0)
            GtkWidget* holder = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
            gtk_box_set_homogeneous(GTK_BOX(holder), FALSE);
#else
            GtkWidget *holder = gtk_hbox_new( FALSE, 4 );
#endif

            GtkEntry *entry = 0;
            GtkWidget *normal;

            if (act->private_data->selectionMode == SELECTION_OPEN) {
	            normal = gtk_combo_box_new_with_model_and_entry (act->private_data->model);
	            gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (normal), act->private_data->labelColumn);

                GtkWidget *child = gtk_bin_get_child( GTK_BIN(normal) );
                if (GTK_IS_ENTRY(child)) {
                    int maxUsed = scan_max_width( act->private_data->model, act->private_data->labelColumn );
                    GtkEntryCompletion *complete = 0;
                    entry = GTK_ENTRY(child);
                    gtk_entry_set_width_chars(entry, maxUsed); /* replace with property */

                    complete = gtk_entry_completion_new();
                    gtk_entry_completion_set_model( complete, act->private_data->model );
                    gtk_entry_completion_set_text_column( complete, act->private_data->labelColumn );
                    gtk_entry_completion_set_inline_completion( complete, FALSE );
                    gtk_entry_completion_set_inline_selection( complete, FALSE );
                    gtk_entry_completion_set_popup_completion( complete, TRUE );
                    gtk_entry_completion_set_popup_set_width( complete, FALSE );
                    gtk_entry_set_completion( entry, complete );

                    g_signal_connect( G_OBJECT(child), "activate", G_CALLBACK(combo_entry_changed_cb), act );
                    g_signal_connect( G_OBJECT(child), "focus-out-event", G_CALLBACK(combo_entry_focus_lost_cb), act );
                }
            } 
	    else {
                GtkCellRenderer * renderer = NULL;
                normal = gtk_combo_box_new_with_model( act->private_data->model );
                if ( act->private_data->iconColumn >= 0 ) {
                    renderer = gtk_cell_renderer_pixbuf_new();
                    gtk_cell_layout_pack_start( GTK_CELL_LAYOUT(normal), renderer, TRUE );

                    /* "icon-name" */
                    gtk_cell_layout_add_attribute( GTK_CELL_LAYOUT(normal), renderer, "stock-id", act->private_data->iconColumn );
                }

                renderer = gtk_cell_renderer_text_new();
                gtk_cell_layout_pack_start( GTK_CELL_LAYOUT(normal), renderer, TRUE );
                gtk_cell_layout_add_attribute( GTK_CELL_LAYOUT(normal), renderer, "text", act->private_data->labelColumn );
            }

            gtk_combo_box_set_active( GTK_COMBO_BOX(normal), act->private_data->active );
            if ( entry && (act->private_data->active == -1) ) {
                gtk_entry_set_text( entry, act->private_data->activeText );
            }

            g_signal_connect( G_OBJECT(normal), "changed", G_CALLBACK(combo_changed_cb), action );

            g_object_set_data( G_OBJECT(holder), "ege-combo-box", normal );
            g_object_set_data( G_OBJECT(act), "ege-combo-box", normal );

            if (act->private_data->appearanceMode == APPEARANCE_COMPACT) {
                gchar*  sss = 0;
                g_object_get( G_OBJECT(action), "short_label", &sss, NULL );
                if (sss) {
                    GtkWidget* lbl = gtk_label_new(sss);
                    gtk_box_pack_start( GTK_BOX(holder), lbl, FALSE, FALSE, 4 );
                    g_free( sss );
                    sss = 0;
                }
            }

            gtk_box_pack_start( GTK_BOX(holder), normal, FALSE, FALSE, 0 );

            {
#if GTK_CHECK_VERSION(3,0,0)
                gtk_widget_set_halign(holder, GTK_ALIGN_START);
                gtk_container_add(GTK_CONTAINER(item), holder);
#else
                GtkWidget *align = gtk_alignment_new(0, 0.5, 0, 0);
                gtk_container_add( GTK_CONTAINER(align), holder);
                gtk_container_add( GTK_CONTAINER(item), align );
#endif
            }
        }

        gtk_widget_show_all( item );
    } else {
        item = GTK_ACTION_CLASS(ege_select_one_action_parent_class)->create_tool_item( action );
    }

    return item;
}
Esempio n. 9
0
static void fm_main_win_init(FmMainWin *self)
{
    GtkWidget *vbox, *menubar, *toolitem, *next_btn, *scroll;
    GtkUIManager* ui;
    GtkActionGroup* act_grp;
    GtkAction* act;
    GtkAccelGroup* accel_grp;

    ++n_wins;

    vbox = gtk_vbox_new(FALSE, 0);

    self->hpaned = gtk_hpaned_new();
    gtk_paned_set_position(GTK_PANED(self->hpaned), 150);

    /* places left pane */
    self->places_view = fm_places_view_new();
    scroll = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
    gtk_container_add(GTK_CONTAINER(scroll), self->places_view);
    gtk_paned_add1(GTK_PANED(self->hpaned), scroll);

    /* folder view */
    self->folder_view = fm_folder_view_new( FM_FV_ICON_VIEW );
    fm_folder_view_set_show_hidden(FM_FOLDER_VIEW(self->folder_view), FALSE);
    fm_folder_view_sort(FM_FOLDER_VIEW(self->folder_view), GTK_SORT_DESCENDING, COL_FILE_NAME);
    fm_folder_view_set_selection_mode(FM_FOLDER_VIEW(self->folder_view), GTK_SELECTION_MULTIPLE);
    g_signal_connect(self->folder_view, "clicked", on_file_clicked, self);
    g_signal_connect(self->folder_view, "status", on_status, self);
    g_signal_connect(self->folder_view, "sel-changed", on_sel_changed, self);

    gtk_paned_add2(GTK_PANED(self->hpaned), self->folder_view);

    /* link places view with folder view. */
    g_signal_connect_swapped(self->places_view, "chdir", G_CALLBACK(fm_main_win_chdir), self);

    /* create menu bar and toolbar */
    ui = gtk_ui_manager_new();
    act_grp = gtk_action_group_new("Main");
    gtk_action_group_add_actions(act_grp, main_win_actions, G_N_ELEMENTS(main_win_actions), self);
    gtk_action_group_add_toggle_actions(act_grp, main_win_toggle_actions, G_N_ELEMENTS(main_win_toggle_actions), self);
    gtk_action_group_add_radio_actions(act_grp, main_win_mode_actions, G_N_ELEMENTS(main_win_mode_actions), FM_FV_ICON_VIEW, on_change_mode, self);
    gtk_action_group_add_radio_actions(act_grp, main_win_sort_type_actions, G_N_ELEMENTS(main_win_sort_type_actions), GTK_SORT_ASCENDING, on_sort_type, self);
    gtk_action_group_add_radio_actions(act_grp, main_win_sort_by_actions, G_N_ELEMENTS(main_win_sort_by_actions), 0, on_sort_by, self);

    accel_grp = gtk_ui_manager_get_accel_group(ui);
    gtk_window_add_accel_group(GTK_WINDOW(self), accel_grp);

    gtk_ui_manager_insert_action_group(ui, act_grp, 0);
    gtk_ui_manager_add_ui_from_string(ui, main_menu_xml, -1, NULL);

    menubar = gtk_ui_manager_get_widget(ui, "/menubar");

    self->toolbar = gtk_ui_manager_get_widget(ui, "/toolbar");
    /* FIXME: should make these optional */
    gtk_toolbar_set_icon_size(GTK_TOOLBAR(self->toolbar), GTK_ICON_SIZE_SMALL_TOOLBAR);
    gtk_toolbar_set_style(GTK_TOOLBAR(self->toolbar), GTK_TOOLBAR_ICONS);

    /* create 'Next' button manually and add a popup menu to it */
    toolitem = g_object_new(GTK_TYPE_MENU_TOOL_BUTTON, NULL);
    gtk_toolbar_insert(GTK_TOOLBAR(self->toolbar), toolitem, 2);
    gtk_widget_show(GTK_WIDGET(toolitem));
    act = gtk_ui_manager_get_action(ui, "/menubar/GoMenu/Next");
    gtk_activatable_set_related_action(GTK_ACTIVATABLE(toolitem), act);

    /* set up history menu */
    self->nav_history = fm_nav_history_new();
    self->history_menu = gtk_menu_new();
    gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolitem), self->history_menu);
    g_signal_connect(toolitem, "show-menu", G_CALLBACK(on_show_history_menu), self);

    self->popup = gtk_ui_manager_get_widget(ui, "/popup");

    gtk_box_pack_start( (GtkBox*)vbox, menubar, FALSE, TRUE, 0 );
    gtk_box_pack_start( (GtkBox*)vbox, self->toolbar, FALSE, TRUE, 0 );

    /* load bookmarks menu */
    load_bookmarks(self, ui);

    /* the location bar */
    self->location = fm_path_entry_new();
    g_signal_connect(self->location, "activate", on_entry_activate, self);
    g_signal_connect(self->folder_view, "loaded", G_CALLBACK(on_view_loaded), (gpointer) self);

    toolitem = gtk_tool_item_new();
    gtk_container_add( GTK_CONTAINER(toolitem), self->location );
    gtk_tool_item_set_expand(GTK_TOOL_ITEM(toolitem), TRUE);
    gtk_toolbar_insert((GtkToolbar*)self->toolbar, toolitem, gtk_toolbar_get_n_items(GTK_TOOLBAR(self->toolbar)) - 1 );

    gtk_box_pack_start( (GtkBox*)vbox, self->hpaned, TRUE, TRUE, 0 );

    /* status bar */
    self->statusbar = gtk_statusbar_new();
    gtk_box_pack_start( (GtkBox*)vbox, self->statusbar, FALSE, TRUE, 0 );
    self->statusbar_ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(self->statusbar), "status");
    self->statusbar_ctx2 = gtk_statusbar_get_context_id(GTK_STATUSBAR(self->statusbar), "status2");

    g_object_unref(act_grp);
    self->ui = ui;

    gtk_container_add( (GtkContainer*)self, vbox );
    gtk_widget_show_all(vbox);

    fm_folder_view_set_show_hidden(FM_FOLDER_VIEW(self->folder_view), FALSE);
    fm_main_win_chdir(self, fm_path_get_home());

    gtk_widget_grab_focus(self->folder_view);
}
Esempio n. 10
0
GtkWidget *
gimp_editor_add_action_button (GimpEditor  *editor,
                               const gchar *group_name,
                               const gchar *action_name,
                               ...)
{
  GimpActionGroup *group;
  GtkAction       *action;
  GtkWidget       *button;
  GtkWidget       *old_child;
  GtkWidget       *image;
  GtkIconSize      button_icon_size;
  GtkReliefStyle   button_relief;
  const gchar     *stock_id;
  gchar           *tooltip;
  const gchar     *help_id;
  GList           *extended = NULL;
  va_list          args;

  g_return_val_if_fail (GIMP_IS_EDITOR (editor), NULL);
  g_return_val_if_fail (action_name != NULL, NULL);
  g_return_val_if_fail (editor->ui_manager != NULL, NULL);

  group = gimp_ui_manager_get_action_group (editor->ui_manager, group_name);

  g_return_val_if_fail (group != NULL, NULL);

  action = gtk_action_group_get_action (GTK_ACTION_GROUP (group),
                                        action_name);

  g_return_val_if_fail (action != NULL, NULL);

  button_icon_size = gimp_editor_ensure_button_box (editor, &button_relief);

  if (GTK_IS_TOGGLE_ACTION (action))
    button = gtk_toggle_button_new ();
  else
    button = gimp_button_new ();

  gtk_button_set_relief (GTK_BUTTON (button), button_relief);

  stock_id = gtk_action_get_stock_id (action);
  tooltip  = g_strdup (gtk_action_get_tooltip (action));

  old_child = gtk_bin_get_child (GTK_BIN (button));

  if (old_child)
    gtk_container_remove (GTK_CONTAINER (button), old_child);

  image = gtk_image_new_from_stock (stock_id, button_icon_size);
  gtk_container_add (GTK_CONTAINER (button), image);
  gtk_widget_show (image);

  gtk_activatable_set_related_action (GTK_ACTIVATABLE (button), action);
  gtk_box_pack_start (GTK_BOX (editor->button_box), button, TRUE, TRUE, 0);
  gtk_widget_show (button);

  va_start (args, action_name);

  action_name = va_arg (args, const gchar *);

  while (action_name)
    {
      GdkModifierType mod_mask;

      mod_mask = va_arg (args, GdkModifierType);

      action = gtk_action_group_get_action (GTK_ACTION_GROUP (group),
                                            action_name);

      if (action && mod_mask)
        {
          ExtendedAction *ext = g_slice_new (ExtendedAction);

          ext->mod_mask = mod_mask;
          ext->action   = action;

          extended = g_list_prepend (extended, ext);

          if (tooltip)
            {
              const gchar *ext_tooltip = gtk_action_get_tooltip (action);

              if (ext_tooltip)
                {
                  gchar *tmp = g_strconcat (tooltip, "\n<b>",
                                            gimp_get_mod_string (mod_mask),
                                            "</b>  ", ext_tooltip, NULL);
                  g_free (tooltip);
                  tooltip = tmp;
                }
            }
        }

      action_name = va_arg (args, const gchar *);
    }

  va_end (args);

  if (extended)
    {
      g_object_set_data_full (G_OBJECT (button), "extended-actions", extended,
                              (GDestroyNotify) gimp_editor_button_extended_actions_free);

      g_signal_connect (button, "extended-clicked",
                        G_CALLBACK (gimp_editor_button_extended_clicked),
                        NULL);
    }

  help_id = g_object_get_qdata (G_OBJECT (action), GIMP_HELP_ID);

  if (tooltip || help_id)
    gimp_help_set_help_data_with_markup (button, tooltip, help_id);

  g_free (tooltip);

  return button;
}
Esempio n. 11
0
/**
 * anjuta_command_bar_add_action_group:
 * @self: An AnjutaCommandBar
 * @group_name: A unique name for this group of entries
 * @entries: (array length=num_entries): A list of entries to add
 * @num_entries: The number of items pointed to by entries
 * @user_data: User data to pass to the entry callback
 * 
 * Adds a group of entries to an AnjutaCommandBar.
 */
void 
anjuta_command_bar_add_action_group (AnjutaCommandBar *self, 
                                     const gchar *group_name, 
                                     const AnjutaCommandBarEntry *entries,
                                     int num_entries, gpointer user_data)
{
	GtkWidget *vbox;
	GtkWidget *scrolled_window;
	GtkWidget *current_vbox;
	GtkActionGroup *action_group;
	int i;
	
	vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
	scrolled_window = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
	                                GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
	                                     GTK_SHADOW_IN);

	g_hash_table_insert (self->priv->widgets, (gchar *) group_name, 
	                     scrolled_window);

	action_group = gtk_action_group_new (group_name);

	g_hash_table_insert (self->priv->action_groups, (gchar *) group_name,
	                     action_group);

	/* The current_vbox is the vbox we're currently adding buttons to. As 
	 * frame entries are encountered, the current box changes to the newly 
	 * created frame vbox. But start by adding any other buttons to the top
	 * level vbox. */
	current_vbox = vbox;

	for (i = 0; i < num_entries; i++)
	{
		if (entries[i].type == ANJUTA_COMMAND_BAR_ENTRY_BUTTON)
		{
			GtkAction *action;
			GtkWidget *button;
			GtkWidget *button_box;
			GtkWidget *button_label;
			

			action = gtk_action_new (entries[i].action_name, _(entries[i].label), 
			                         _(entries[i].tooltip), entries[i].stock_icon);
			button = gtk_button_new();
			button_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
			gtk_container_add (GTK_CONTAINER (button), button_box);

			gtk_action_group_add_action (action_group, action);
			
			gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);

			if (entries[i].stock_icon)
			{
				GtkWidget* image;
				image = gtk_action_create_icon (action, 
				                                GTK_ICON_SIZE_BUTTON);
				gtk_box_pack_start (GTK_BOX (button_box), image, FALSE, FALSE, 5);
			}

			gtk_activatable_set_related_action (GTK_ACTIVATABLE (button), 
			                                    action);
			button_label = gtk_label_new (gettext(entries[i].label));
			gtk_label_set_width_chars (GTK_LABEL (button_label), self->priv->max_text_width);
			gtk_label_set_line_wrap (GTK_LABEL (button_label), TRUE);
			gtk_misc_set_alignment (GTK_MISC (button_label), 0, 0.5);
			gtk_box_pack_start (GTK_BOX (button_box), button_label,
			                    FALSE, FALSE, 5);
			gtk_widget_show_all (button);
			

			g_signal_connect (G_OBJECT (action), "activate",
			                  entries[i].callback,
			                  user_data);

			/* Left-align button contents */
			g_object_set (G_OBJECT (button), "xalign", 0.0, NULL);

			gtk_box_pack_start (GTK_BOX (current_vbox), button, FALSE, FALSE, 
			                    2);
		}
		else
		{
			gchar *frame_label_text;
			GtkWidget *frame_label;
			GtkWidget *frame;
			GtkWidget *frame_vbox;
			
			frame_label_text = g_strdup_printf ("<b>%s</b>", _(entries[i].label));
			frame_label = gtk_label_new (NULL);
			frame = gtk_frame_new (NULL);
			
			gtk_label_set_markup(GTK_LABEL (frame_label), frame_label_text);
			gtk_frame_set_label_widget (GTK_FRAME (frame), frame_label);

			g_free (frame_label_text);
			
			frame_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);

			g_object_set (G_OBJECT (frame), "shadow-type", GTK_SHADOW_NONE, 
			              NULL);

			gtk_container_add (GTK_CONTAINER (frame), frame_vbox);
			gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 2);

			current_vbox = frame_vbox;
		}
	}

	gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window),
	                                       vbox);
	gtk_widget_show_all (scrolled_window);
	gtk_notebook_append_page (GTK_NOTEBOOK (self), scrolled_window, NULL);
}
Esempio n. 12
0
static GObject *constructor (GType type,
			     guint n_properties,
			     GObjectConstructParam * properties)
{
	AnnumShellWindow *self;
	AnnumShellWindowPrivate *priv;
	GObject *object;
	GObjectClass *parent_class;
	GtkAction *action;
	GdkScreen *screen;
	gint monitor;
	GdkRectangle rect;
	GtkRadioAction *radio_action;
	GtkWidget *button_image;

	parent_class = G_OBJECT_CLASS (annum_shell_window_parent_class);
	object = parent_class->constructor (type, n_properties, properties);

	self = ANNUM_SHELL_WINDOW (object);
	priv = self->priv = GET_PRIVATE (self);

	gtk_widget_realize (GTK_WIDGET (self));

	screen = gdk_screen_get_default ();
	monitor =
	    gdk_screen_get_monitor_at_window (screen,
					      GTK_WIDGET (self)->window);
	gdk_screen_get_monitor_geometry (screen, monitor, &rect);
	gtk_window_set_default_size (GTK_WINDOW (self), rect.width,
				     rect.height);
	gtk_window_set_decorated (GTK_WINDOW (self), FALSE);

	/* This is a fake action, just because EShellView needs one, but we
	 * have only one view, so an action to switch views is needless.
	 */
	radio_action = gtk_radio_action_new ("Calendar", NULL, NULL, NULL, 0);

	priv->shell_view = g_object_new (ANNUM_TYPE_SHELL_VIEW,
					 "action", radio_action,
					 "shell-window", self, NULL);

	g_signal_connect_swapped (priv->shell_view, "date-changed",
				  G_CALLBACK (date_changed_cb),
				  self);

	/* Main layout */
	priv->vbox = gtk_vbox_new (FALSE, 0);
	gtk_container_add (GTK_CONTAINER (self), priv->vbox);

	priv->toolbox = gtk_hbox_new (FALSE, 0);
	gtk_container_set_border_width (GTK_CONTAINER (priv->toolbox), 6);
	gtk_box_pack_start (GTK_BOX (priv->vbox), priv->toolbox,
			    FALSE, FALSE, 0);

	/* Top toolbox */
	priv->today_button = gtk_toggle_button_new ();
	gtk_box_pack_start (GTK_BOX (priv->toolbox), priv->today_button, FALSE, FALSE, 0);

	priv->week_button = gtk_toggle_button_new ();
	gtk_box_pack_start (GTK_BOX (priv->toolbox), priv->week_button, FALSE, FALSE, 0);

	priv->month_button = gtk_toggle_button_new ();
	gtk_box_pack_start (GTK_BOX (priv->toolbox), priv->month_button, FALSE, FALSE, 0);

	priv->quickadd_entry = gtk_entry_new ();
	gtk_entry_set_text (GTK_ENTRY (priv->quickadd_entry), "This space intentionally left blank.");
	gtk_widget_set_sensitive (priv->quickadd_entry, FALSE);
	gtk_box_pack_start (GTK_BOX (priv->toolbox), priv->quickadd_entry, TRUE, TRUE, 0);

	priv->quit_button = gtk_button_new ();
	g_signal_connect (priv->quit_button, "clicked",
			  G_CALLBACK (close_window_cb), self);
	gtk_box_pack_start (GTK_BOX (priv->toolbox), priv->quit_button, FALSE, FALSE, 0);

	button_image = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_LARGE_TOOLBAR);
	gtk_container_add (GTK_CONTAINER (priv->quit_button), button_image);

        /* Sidebar, and main content view */
	priv->hpaned = gtk_hpaned_new ();
	/* FIXME: store the position somehow? */
	gtk_paned_set_position (GTK_PANED (priv->hpaned), 250);
	gtk_box_pack_start (GTK_BOX (priv->vbox), priv->hpaned,
			    TRUE, TRUE, 0);

	priv->sidebar =
	    e_shell_view_get_shell_sidebar (E_SHELL_VIEW (priv->shell_view));
	gtk_paned_add1 (GTK_PANED (priv->hpaned), GTK_WIDGET (priv->sidebar));

	priv->content_view =
	    e_shell_view_get_shell_content (E_SHELL_VIEW (priv->shell_view));
	gtk_paned_add2 (GTK_PANED (priv->hpaned),
			GTK_WIDGET (priv->content_view));

	/* Set up actions */
	priv->action_group = gtk_action_group_new ("AnnumActions");
	gtk_action_group_add_radio_actions (priv->action_group,
					    annum_view_actions,
					    G_N_ELEMENTS (annum_view_actions),
					    ANNUM_VIEW_TODAY,
					    G_CALLBACK (annum_shell_window_change_view_cb),
					    self);

	/* Today */
	action = gtk_action_group_get_action (priv->action_group, "ShowToday");
	gtk_activatable_set_related_action (GTK_ACTIVATABLE (priv->today_button), action);

	/* Week */
	action = gtk_action_group_get_action (priv->action_group, "ShowWeek");
	gtk_activatable_set_related_action (GTK_ACTIVATABLE (priv->week_button), action);

	/* Month */
	action = gtk_action_group_get_action (priv->action_group, "ShowMonth");
	gtk_activatable_set_related_action (GTK_ACTIVATABLE (priv->month_button), action);

	return object;
}
Esempio n. 13
0
static void
ephy_toolbar_constructed (GObject *object)
{
  EphyToolbarPrivate *priv = EPHY_TOOLBAR (object)->priv;
  GtkActionGroup *action_group;
  GtkAction *action;
  GtkToolItem *back_forward, *location_stop_reload, *tool_item;
  GtkWidget *tool_button, *box, *location, *toolbar;
  GtkSizeGroup *size;

  G_OBJECT_CLASS (ephy_toolbar_parent_class)->constructed (object);

  toolbar = GTK_WIDGET (object);

  /* Create a GtkSizeGroup to sync the height of the location entry, and
   * the stop/reload button. */
  size = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);

  /* Set the MENUBAR style class so it's possible to drag the app
   * using the toolbar. */
  gtk_style_context_add_class (gtk_widget_get_style_context (toolbar),
                               GTK_STYLE_CLASS_MENUBAR);

  /* Back and Forward */
  back_forward = gtk_tool_item_new ();
  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);

  /* Back */
  tool_button = ephy_middle_clickable_button_new ();
  /* FIXME: apparently we need an image inside the button for the action
   * icon to appear. */
  gtk_button_set_image (GTK_BUTTON (tool_button), gtk_image_new ());
  action_group = ephy_window_get_toolbar_action_group (priv->window);
  action = gtk_action_group_get_action (action_group, "NavigationBack");
  gtk_activatable_set_related_action (GTK_ACTIVATABLE (tool_button),
                                      action);
  gtk_button_set_label (GTK_BUTTON (tool_button), NULL);
  gtk_container_add (GTK_CONTAINER (box), GTK_WIDGET (tool_button));

  /* Forward */
  tool_button = ephy_middle_clickable_button_new ();
  /* FIXME: apparently we need an image inside the button for the action
   * icon to appear. */
  gtk_button_set_image (GTK_BUTTON (tool_button), gtk_image_new ());
  action = gtk_action_group_get_action (action_group, "NavigationForward");
  gtk_activatable_set_related_action (GTK_ACTIVATABLE (tool_button),
                                      action);
  gtk_button_set_label (GTK_BUTTON (tool_button), NULL);
  gtk_container_add (GTK_CONTAINER (box), GTK_WIDGET (tool_button));

  gtk_style_context_add_class (gtk_widget_get_style_context (box),
                               "raised");
  gtk_style_context_add_class (gtk_widget_get_style_context (box),
                               "linked");

  gtk_container_add (GTK_CONTAINER (back_forward), box);
  gtk_container_add (GTK_CONTAINER (toolbar), GTK_WIDGET (back_forward));
  gtk_widget_show_all (GTK_WIDGET (back_forward));
  if (gtk_widget_get_direction (GTK_WIDGET (back_forward)) == GTK_TEXT_DIR_RTL)
    gtk_widget_set_margin_left (GTK_WIDGET (back_forward), 12);
  else
    gtk_widget_set_margin_right (GTK_WIDGET (back_forward), 12);

  /* Location and Reload/Stop */
  location_stop_reload = gtk_tool_item_new ();
  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);

  /* Location */
  priv->entry = location = ephy_location_entry_new ();
  gtk_box_pack_start (GTK_BOX (box), location,
                      TRUE, TRUE, 0);
  gtk_style_context_add_class (gtk_widget_get_style_context (box),
                               "location-entry");

  /* Reload/Stop */
  tool_button = gtk_button_new ();
  /* FIXME: apparently we need an image inside the button for the action
   * icon to appear. */
  gtk_button_set_image (GTK_BUTTON (tool_button), gtk_image_new ());
  action = gtk_action_group_get_action (action_group, "ViewCombinedStopReload");
  gtk_activatable_set_related_action (GTK_ACTIVATABLE (tool_button),
                                      action);
  gtk_container_add (GTK_CONTAINER (box), GTK_WIDGET (tool_button));

  gtk_container_add (GTK_CONTAINER (location_stop_reload), box);
  gtk_container_child_set (GTK_CONTAINER (toolbar),
                           GTK_WIDGET (location_stop_reload),
                           "expand", TRUE,
                           NULL);
  
  gtk_container_add (GTK_CONTAINER (toolbar), GTK_WIDGET (location_stop_reload));

  gtk_size_group_add_widget (size, tool_button);
  gtk_size_group_add_widget (size, location);
  g_object_unref (size);

  if (gtk_widget_get_direction (GTK_WIDGET (location_stop_reload)) == GTK_TEXT_DIR_RTL)
    gtk_widget_set_margin_left (GTK_WIDGET (location_stop_reload), 12);
  else
    gtk_widget_set_margin_right (GTK_WIDGET (location_stop_reload), 12);

  gtk_widget_show_all (GTK_WIDGET (location_stop_reload));

  /* New Tab */
  tool_item = gtk_tool_item_new ();
  tool_button = gtk_button_new ();
  /* FIXME: apparently we need an image inside the button for the action
   * icon to appear. */
  gtk_button_set_image (GTK_BUTTON (tool_button), gtk_image_new ());
  action = gtk_action_group_get_action (action_group, "FileNewTab");
  gtk_activatable_set_related_action (GTK_ACTIVATABLE (tool_button),
                                      action);
  gtk_button_set_label (GTK_BUTTON (tool_button), NULL);
  gtk_container_add (GTK_CONTAINER (tool_item), tool_button);
  gtk_container_add (GTK_CONTAINER (toolbar), GTK_WIDGET (tool_item));

  if (gtk_widget_get_direction (GTK_WIDGET (tool_item)) == GTK_TEXT_DIR_RTL)
    gtk_widget_set_margin_left (GTK_WIDGET (tool_item), 4);
  else
    gtk_widget_set_margin_right (GTK_WIDGET (tool_item), 4);

  gtk_widget_show_all (GTK_WIDGET (tool_item));


  /* Page Menu */
  tool_item = gtk_tool_item_new ();
  tool_button = gtk_button_new ();
  gtk_widget_set_name (GTK_WIDGET (tool_button), "ephy-page-menu-button");
  /* FIXME: apparently we need an image inside the button for the action
   * icon to appear. */
  gtk_button_set_image (GTK_BUTTON (tool_button), gtk_image_new ());
  action = gtk_action_group_get_action (action_group, "PageMenu");
  gtk_activatable_set_related_action (GTK_ACTIVATABLE (tool_button),
                                      action);
  gtk_container_add (GTK_CONTAINER (tool_item), tool_button);
  gtk_container_add (GTK_CONTAINER (toolbar), GTK_WIDGET (tool_item));
  gtk_widget_show_all (GTK_WIDGET (tool_item));
}
Esempio n. 14
0
static void
html_editor_paragraph_dialog_constructed (GObject *object)
{
	GtkGrid *main_layout, *grid;
	GtkWidget *widget;
	EHTMLEditor *editor;
	EHTMLEditorParagraphDialog *dialog;

	/* Chain up to parent's method. */
	G_OBJECT_CLASS (e_html_editor_paragraph_dialog_parent_class)->constructed (object);

	dialog = E_HTML_EDITOR_PARAGRAPH_DIALOG (object);
	editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));

	main_layout = e_html_editor_dialog_get_container (E_HTML_EDITOR_DIALOG (dialog));

	/* == General == */
	widget = gtk_label_new ("");
	gtk_label_set_markup (GTK_LABEL (widget), _("<b>General</b>"));
	gtk_misc_set_alignment (GTK_MISC (widget), 0, 0.5);
	gtk_grid_attach (main_layout, widget, 0, 0, 1, 1);

	grid = GTK_GRID (gtk_grid_new ());
	gtk_grid_set_row_spacing (grid, 5);
	gtk_grid_set_column_spacing (grid, 5);
	gtk_grid_attach (main_layout, GTK_WIDGET (grid), 0, 1, 1, 1);
	gtk_widget_set_margin_left (GTK_WIDGET (grid), 10);

	/* Style */
	widget = e_action_combo_box_new_with_action (
		GTK_RADIO_ACTION (e_html_editor_get_action (editor, "style-normal")));
	gtk_widget_set_hexpand (widget, TRUE);
	gtk_grid_attach (grid, widget, 1, 0, 1, 1);
	dialog->priv->style_combo = widget;

	widget = gtk_label_new_with_mnemonic (_("_Style:"));
	gtk_label_set_justify (GTK_LABEL (widget), GTK_JUSTIFY_RIGHT);
	gtk_label_set_mnemonic_widget (GTK_LABEL (widget), dialog->priv->style_combo);
	gtk_grid_attach (grid, widget, 0, 0, 1, 1);

	/* == Alignment == */
	widget = gtk_label_new ("");
	gtk_label_set_markup (GTK_LABEL (widget), _("<b>Alignment</b>"));
	gtk_misc_set_alignment (GTK_MISC (widget), 0, 0.5);
	gtk_grid_attach (main_layout, widget, 0, 2, 1, 1);

	grid = GTK_GRID (gtk_grid_new ());
	gtk_grid_set_row_spacing (grid, 5);
	gtk_grid_set_column_spacing (grid, 5);
	gtk_grid_attach (main_layout, GTK_WIDGET (grid), 0, 3, 1, 1);
	gtk_widget_set_margin_left (GTK_WIDGET (grid), 10);

	/* Left */
	widget = gtk_toggle_button_new_with_label (_("_Left"));
	gtk_button_set_use_stock (GTK_BUTTON (widget), TRUE);
	gtk_activatable_set_related_action (
		GTK_ACTIVATABLE (widget),
		e_html_editor_get_action (editor, "justify-left"));
	gtk_grid_attach (grid, widget, 0, 0, 1, 1);
	dialog->priv->left_button = widget;

	/* Center */
	widget = gtk_toggle_button_new_with_label (_("_Center"));
	gtk_button_set_use_stock (GTK_BUTTON (widget), TRUE);
	gtk_grid_attach (grid, widget, 1, 0, 1, 1);
	gtk_activatable_set_related_action (
		GTK_ACTIVATABLE (widget),
		e_html_editor_get_action (editor, "justify-center"));
	dialog->priv->center_button = widget;

	/* Right */
	widget = gtk_toggle_button_new_with_label (_("_Right"));
	gtk_button_set_use_stock (GTK_BUTTON (widget), TRUE);
	gtk_grid_attach (grid, widget, 2, 0, 1, 1);
	gtk_activatable_set_related_action (
		GTK_ACTIVATABLE (widget),
		e_html_editor_get_action (editor, "justify-right"));
	dialog->priv->right_button = widget;

	gtk_widget_show_all (GTK_WIDGET (main_layout));
}
Esempio n. 15
0
Liveplay::Liveplay(
    const gx_system::CmdlineOptions& options, gx_engine::GxMachineBase& machine_,
    const std::string& fname, const GxActions& actions_)
    : bld(),
      machine(machine_),
      actions(actions_),
      use_composite(),
      brightness_adj(),
      background_adj(),
      keyswitch(machine_, sigc::mem_fun(this, &Liveplay::display)),
      midi_conn(),
      window(),
      mouse_hide_conn() {
    const char *id_list[] = {"LivePlay", 0};
    bld = gx_gui::GxBuilder::create_from_file(fname, &machine, id_list);
    bld->get_toplevel("LivePlay", window);

    bld->find_widget("liveplay_bank", liveplay_bank);
    bld->find_widget("liveplay_preset", liveplay_preset);
    bld->find_widget("liveplay_bypass_image", bypass_image);
    bld->find_widget("liveplay_mute_image", mute_image);
    bld->find_widget("liveplay_canvas", liveplay_canvas);
    bld->find_widget("brightness_slider", brightness_slider);
    bld->find_widget("brightness_box", brightness_box);
    bld->find_widget("background_slider", background_slider);
    bld->find_widget("liveplay_exit:barbutton", liveplay_exit);
    bld->find_widget("liveplay_tuner", tuner);
    bld->find_widget("liveplay_midictrl_table", midictrl_table);
    brightness_adj = brightness_slider->get_adjustment();
    background_adj = background_slider->get_adjustment();
    MyPaintBox *liveplay_paintbox;
    bld->find_widget_derived(
        "liveplay_paintbox", liveplay_paintbox,
        sigc::bind(
            sigc::ptr_fun(MyPaintBox::create_from_builder),
            background_adj));
    Glib::RefPtr<Gdk::Pixbuf> pb;
    try {
        pb = Gdk::Pixbuf::create_from_file(
                 options.get_style_filepath("bypass.svg"), 300, 150);
        bypass_image->set(pb);
    } catch (const Glib::FileError& ex) {
        gx_print_error("liveplay", ex.what());
    } catch (const Gdk::PixbufError& ex) {
        gx_print_error("liveplay", ex.what());
    } catch(...) {
        gx_print_error("liveplay", "failed to load pixmap bypass.svg");
    }
    try {
        pb = Gdk::Pixbuf::create_from_file(
                 options.get_style_filepath("mute.svg"), 300, 150);
        mute_image->set(pb);
    } catch (const Glib::FileError& ex) {
        gx_print_error("liveplay", ex.what());
    } catch (const Gdk::PixbufError& ex) {
        gx_print_error("liveplay", ex.what());
    } catch(...) {
        gx_print_error("liveplay", "failed to load pixmap mute.svg");
    }
    use_composite = window->get_display()->supports_composite();
    if (use_composite) {
        brightness_adj->signal_value_changed().connect(sigc::mem_fun(this, &Liveplay::on_brightness_changed));
        liveplay_canvas->signal_realize().connect(sigc::mem_fun(this, &Liveplay::on_realize));
        window->signal_expose_event().connect(
            sigc::mem_fun(this, &Liveplay::window_expose_event), true);
    } else {
        brightness_box->hide();
    }
    background_adj->signal_value_changed().connect(
        sigc::mem_fun(this, &Liveplay::on_background_changed));
    Glib::RefPtr<Gdk::Screen> screen = liveplay_canvas->get_screen();
    Glib::RefPtr<Gdk::Colormap> rgba = screen->get_rgba_colormap();
    liveplay_canvas->set_colormap(rgba);
    liveplay_canvas->set_app_paintable(true);
    window->signal_delete_event().connect(
        sigc::mem_fun(this, &Liveplay::on_delete));
    window->add_events(Gdk::POINTER_MOTION_HINT_MASK|Gdk::POINTER_MOTION_MASK);
    window->signal_motion_notify_event().connect(
        sigc::mem_fun(*this, &Liveplay::pointer_motion));

    gtk_activatable_set_related_action(
        GTK_ACTIVATABLE(liveplay_exit->gobj()), GTK_ACTION(actions.live_play->gobj()));
    Glib::RefPtr<Gtk::AccelGroup> ag = Gtk::AccelGroup::create();
    GClosure *cl = g_cclosure_new(G_CALLBACK(do_action), (gpointer)(actions.live_play->gobj()), 0);
    gtk_accel_group_connect_by_path(ag->gobj(), actions.live_play->get_accel_path().c_str(), cl);
    cl = g_cclosure_new(G_CALLBACK(do_action), (gpointer)(actions.live_play->gobj()), 0);
    gtk_accel_group_connect(ag->gobj(), GDK_KEY_Escape, (GdkModifierType)0, (GtkAccelFlags)0, cl);

    cl = g_cclosure_new(G_CALLBACK(do_action), (gpointer)(actions.livetuner->gobj()), 0);
    gtk_accel_group_connect(ag->gobj(), GDK_KEY_Return, (GdkModifierType)0, (GtkAccelFlags)0, cl);

    cl = g_cclosure_new(G_CALLBACK(do_action), (gpointer)(actions.quit->gobj()), 0);
    gtk_accel_group_connect_by_path(ag->gobj(), actions.quit->get_accel_path().c_str(), cl);

    cl = g_cclosure_new(G_CALLBACK(on_keyboard_toggle_mute), (gpointer)this, 0);
    gtk_accel_group_connect(ag->gobj(), GDK_KEY_M, GDK_CONTROL_MASK, (GtkAccelFlags)0, cl);

    cl = g_cclosure_new(G_CALLBACK(on_keyboard_toggle_bypass), (gpointer)this, 0);
    gtk_accel_group_connect(ag->gobj(), GDK_KEY_B, GDK_CONTROL_MASK, (GtkAccelFlags)0, cl);

    cl = g_cclosure_new(G_CALLBACK(on_keyboard_arrows), (gpointer)this, 0);
    gtk_accel_group_connect(ag->gobj(), GDK_KEY_Left, GDK_CONTROL_MASK, (GtkAccelFlags)0, cl);
    cl = g_cclosure_new(G_CALLBACK(on_keyboard_arrows), (gpointer)this, 0);
    gtk_accel_group_connect(ag->gobj(), GDK_KEY_Right, GDK_CONTROL_MASK, (GtkAccelFlags)0, cl);
    cl = g_cclosure_new(G_CALLBACK(on_keyboard_arrows), (gpointer)this, 0);
    gtk_accel_group_connect(ag->gobj(), GDK_KEY_Up, GDK_CONTROL_MASK, (GtkAccelFlags)0, cl);
    cl = g_cclosure_new(G_CALLBACK(on_keyboard_arrows), (gpointer)this, 0);
    gtk_accel_group_connect(ag->gobj(), GDK_KEY_Down, GDK_CONTROL_MASK, (GtkAccelFlags)0, cl);

    for (int n = GDK_KEY_0; n <= GDK_KEY_9; ++n) {
        cl = g_cclosure_new(G_CALLBACK(on_keyboard_preset_select), (gpointer)this, 0);
        gtk_accel_group_connect(ag->gobj(), n, (GdkModifierType)0, (GtkAccelFlags)0, cl);
    }
    for (int n = GDK_KEY_KP_0; n <= GDK_KEY_KP_9; ++n) {
        cl = g_cclosure_new(G_CALLBACK(on_keyboard_preset_select), (gpointer)this, 0);
        gtk_accel_group_connect(ag->gobj(), n, (GdkModifierType)0, (GtkAccelFlags)0, cl);
    }
    for (int n = GDK_KEY_A; n <= GDK_KEY_Z; ++n) {
        cl = g_cclosure_new(G_CALLBACK(on_keyboard_preset_select), (gpointer)this, 0);
        gtk_accel_group_connect(ag->gobj(), n, (GdkModifierType)0, (GtkAccelFlags)0, cl);
    }

    cl = g_cclosure_new(G_CALLBACK(on_keyboard_mode_switch), (gpointer)this, 0);
    gtk_accel_group_connect(ag->gobj(), GDK_KEY_space, (GdkModifierType)0, (GtkAccelFlags)0, cl);
    machine.tuner_switcher_signal_display().connect(
        sigc::mem_fun(this, &Liveplay::display));
    machine.tuner_switcher_signal_set_state().connect(
        sigc::mem_fun(this, &Liveplay::set_display_state));
    machine.tuner_switcher_signal_selection_done().connect(
        sigc::mem_fun(this, &Liveplay::on_selection_done));

    window->add_accel_group(ag);

    machine.signal_state_change().connect(
        sigc::mem_fun(this, &Liveplay::on_engine_state_change));
    machine.signal_selection_changed().connect(
        sigc::mem_fun(this, &Liveplay::on_selection_changed));

    on_engine_state_change(machine.get_state());
    on_selection_changed();
}
Esempio n. 16
0
void
browser_dialog_open (const gchar *plug_in_binary)
{
  GtkWidget   *window;
  GtkWidget   *main_vbox;
  GtkWidget   *vbox;
  GtkWidget   *toolbar;
  GtkWidget   *paned;
  GtkWidget   *scrolled;
  GtkToolItem *item;
  GtkAction   *action;
  DialogData   data = { 720, 560, 240, TRUE, 1.0 };

  gimp_ui_init (plug_in_binary, TRUE);

  gimp_get_data (GIMP_HELP_BROWSER_DIALOG_DATA, &data);

  /*  the dialog window  */
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), _("GIMP Help Browser"));
  gtk_window_set_role (GTK_WINDOW (window), plug_in_binary);

  gtk_window_set_default_size (GTK_WINDOW (window), data.width, data.height);

  g_signal_connect (window, "destroy",
                    G_CALLBACK (gtk_main_quit),
                    NULL);

  window_set_icons (window);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
  gtk_container_add (GTK_CONTAINER (window), vbox);
  gtk_widget_show (vbox);

  ui_manager = ui_manager_new (window);

  toolbar = gtk_ui_manager_get_widget (ui_manager, "/help-browser-toolbar");
  gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
  gtk_box_pack_start (GTK_BOX (vbox), toolbar, FALSE, FALSE, 0);
  gtk_widget_show (toolbar);

  item = g_object_new (GTK_TYPE_MENU_TOOL_BUTTON, NULL);
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, 0);
  gtk_widget_show (GTK_WIDGET (item));

  action = gtk_ui_manager_get_action (ui_manager,
                                      "/ui/help-browser-popup/forward");
  gtk_activatable_set_related_action (GTK_ACTIVATABLE (item), action);
  g_object_notify (G_OBJECT (action), "tooltip");
  button_next = GTK_WIDGET (item);

  item = g_object_new (GTK_TYPE_MENU_TOOL_BUTTON, NULL);
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, 0);
  gtk_widget_show (GTK_WIDGET (item));

  action = gtk_ui_manager_get_action (ui_manager,
                                      "/ui/help-browser-popup/back");
  gtk_activatable_set_related_action (GTK_ACTIVATABLE (item), action);
  g_object_notify (G_OBJECT (action), "tooltip");
  button_prev = GTK_WIDGET (item);

  item =
    GTK_TOOL_ITEM (gtk_ui_manager_get_widget (ui_manager,
                                              "/help-browser-toolbar/space"));
  gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM (item), FALSE);
  gtk_tool_item_set_expand (item, TRUE);

  /*  the horizontal paned  */
  paned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
  gtk_box_pack_start (GTK_BOX (vbox), paned, TRUE, TRUE, 0);
  gtk_widget_show (paned);

  scrolled = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
                                  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_paned_add1 (GTK_PANED (paned), scrolled);
  gtk_paned_set_position (GTK_PANED (paned), data.paned_position);

  sidebar = scrolled;

  if (data.show_index)
    gtk_widget_show (sidebar);

  tree_view = gtk_tree_view_new ();
  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), FALSE);
  gtk_container_add (GTK_CONTAINER (scrolled), tree_view);
  gtk_widget_show (tree_view);

  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view), -1,
                                               NULL,
                                               gtk_cell_renderer_text_new (),
                                               "text", 1,
                                               NULL);

  g_signal_connect (tree_view, "row-activated",
                    G_CALLBACK (row_activated),
                    NULL);

  /*  HTML view  */
  main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
  gtk_widget_show (main_vbox);
  gtk_paned_pack2 (GTK_PANED (paned), main_vbox, TRUE, TRUE);

  scrolled = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
                                  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

  gtk_widget_set_size_request (scrolled, 300, 200);
  gtk_box_pack_start (GTK_BOX (main_vbox), scrolled, TRUE, TRUE, 0);
  gtk_widget_show (scrolled);

  view = webkit_web_view_new ();
  webkit_web_view_set_maintains_back_forward_list (WEBKIT_WEB_VIEW (view),
                                                   TRUE);
  gtk_container_add (GTK_CONTAINER (scrolled), view);
  gtk_widget_show (view);

  g_signal_connect (view, "realize",
                    G_CALLBACK (view_realize),
                    NULL);
  g_signal_connect (view, "unrealize",
                    G_CALLBACK (view_unrealize),
                    NULL);

  g_signal_connect (view, "popup-menu",
                    G_CALLBACK (view_popup_menu),
                    NULL);
  g_signal_connect (view, "button-press-event",
                    G_CALLBACK (view_button_press),
                    NULL);
  g_signal_connect (view, "key-press-event",
                    G_CALLBACK (view_key_press),
                    NULL);

  webkit_web_view_set_zoom_level (WEBKIT_WEB_VIEW (view), data.zoom);

  g_signal_connect (view, "title-changed",
                    G_CALLBACK (title_changed),
                    window);

  g_signal_connect (view, "load-started",
                    G_CALLBACK (load_started),
                    NULL);
  g_signal_connect (view, "load-finished",
                    G_CALLBACK (load_finished),
                    NULL);

  gtk_widget_grab_focus (view);

  g_signal_connect (window, "unmap",
                    G_CALLBACK (dialog_unmap),
                    paned);

  update_actions ();

  /* Searchbar */
  searchbar = build_searchbar ();
  gtk_box_pack_start (GTK_BOX (main_vbox), searchbar, FALSE, FALSE, 0);
}
Esempio n. 17
0
/**
 * Constructor
 */
GtkWidget *create_control_window(GtkWidget *parent)
{
    GtkWidget *pp_button, *next_button, *prev_button, *ff_button;
    GtkWidget *vol, *progress, *hbox, *play_image;
    int new_volume;
    /* Create window */
    GtkWidget *base = gtk_event_box_new();
    GtkWidget *ali = gtk_alignment_new(0.5,0,0.6,1);
    g_signal_connect(G_OBJECT(base), "enter-notify-event" ,
            G_CALLBACK(control_window_enter_notify_event), NULL);
    g_signal_connect(G_OBJECT(base), "leave-notify-event" ,
            G_CALLBACK(control_window_leave_notify_event), NULL);
    /* Overwrite background drawing */
    gtk_widget_set_app_paintable(base, TRUE);
    g_signal_connect(G_OBJECT(base), "draw",
        G_CALLBACK(expose_window), NULL);

    hbox = gtk_hbox_new(FALSE, 6);
    g_object_set_data(G_OBJECT(base), "hbox" , hbox);
    gtk_container_add(GTK_CONTAINER(base), ali);
    gtk_container_add(GTK_CONTAINER(ali), hbox);
    gtk_container_set_border_width(GTK_CONTAINER(ali), 1);

    /* Previous button */
    ff_button = gtk_button_new();
    gtk_container_add(GTK_CONTAINER(ff_button),
        gtk_image_new_from_stock(GTK_STOCK_LEAVE_FULLSCREEN,
        GTK_ICON_SIZE_BUTTON));
    gtk_button_set_relief(GTK_BUTTON(ff_button), GTK_RELIEF_NONE);
    gtk_box_pack_start(GTK_BOX(hbox), ff_button, FALSE, FALSE, 0);
    g_signal_connect(G_OBJECT(ff_button), "clicked",
        G_CALLBACK(control_window_leave_fullscreen), parent);
    /* Volume button */
    vol = (GtkWidget *)gtk_volume_button_new();
    gtk_box_pack_end(GTK_BOX(hbox), vol, FALSE, FALSE, 0);
    new_volume = mpd_status_get_volume(connection);
    gtk_scale_button_set_value(GTK_SCALE_BUTTON(vol), new_volume/100.0);
    g_object_set_data(G_OBJECT(base), "vol", vol);
    g_signal_connect(G_OBJECT(vol), "value_changed",
        G_CALLBACK(playlist_player_volume_changed), NULL);
    /* Progress */
    progress = (GtkWidget *)gmpc_progress_new();
    gmpc_progress_set_hide_text(GMPC_PROGRESS(progress), FALSE);
    gtk_box_pack_start(GTK_BOX(hbox), progress, TRUE, TRUE, 0);
    g_object_set_data(G_OBJECT(base), "progress", progress);
    g_signal_connect(G_OBJECT(progress), "seek-event", G_CALLBACK(pl3_pb_seek_event),
            NULL);

    /* Previous button */
    prev_button = gtk_button_new();
    gtk_container_add(GTK_CONTAINER(prev_button),
        gtk_image_new_from_stock("gtk-media-previous", GTK_ICON_SIZE_BUTTON));
    gtk_activatable_set_related_action(GTK_ACTIVATABLE(prev_button),
        GTK_ACTION(gtk_builder_get_object(pl3_xml, "MPDPrevious")));
    gtk_button_set_relief(GTK_BUTTON(prev_button), GTK_RELIEF_NONE);
    gtk_box_pack_start(GTK_BOX(hbox), prev_button, FALSE, FALSE, 0);

    /* Play button */
    pp_button = gtk_button_new();
    if(mpd_player_get_state(connection) == MPD_PLAYER_PLAY)
    {
        play_image = gtk_image_new_from_stock("gtk-media-pause", GTK_ICON_SIZE_BUTTON);
    }
    else
    {
        play_image = gtk_image_new_from_stock("gtk-media-play", GTK_ICON_SIZE_BUTTON);
    }
    gtk_container_add(GTK_CONTAINER(pp_button), play_image);
    g_object_set_data(G_OBJECT(base), "play_image", play_image);

    gtk_activatable_set_related_action(GTK_ACTIVATABLE(pp_button),
        GTK_ACTION(gtk_builder_get_object(pl3_xml, "MPDPlayPause")));
    gtk_button_set_relief(GTK_BUTTON(pp_button), GTK_RELIEF_NONE);
    gtk_box_pack_start(GTK_BOX(hbox), pp_button, FALSE, FALSE, 0);

    /* Next */
    next_button = gtk_button_new();
    gtk_container_add(GTK_CONTAINER(next_button),
        gtk_image_new_from_stock("gtk-media-next", GTK_ICON_SIZE_BUTTON));
    gtk_activatable_set_related_action(GTK_ACTIVATABLE(next_button),
        GTK_ACTION(gtk_builder_get_object(pl3_xml, "MPDNext")));
    gtk_button_set_relief(GTK_BUTTON(next_button), GTK_RELIEF_NONE);
    gtk_box_pack_start(GTK_BOX(hbox), next_button, FALSE, FALSE, 0);

    /* Change colors */
    control_window_modify_colors(base);
    gtk_widget_show_all(base);

    timeout = g_timeout_add_seconds(5, (GSourceFunc) gtk_widget_hide, hbox);
    return base;
}