static void
connect_proxy_cb (GtkUIManager *manager,
                  GtkAction *action,
                  GtkWidget *proxy,
                  NautilusWindow *window)
{
    GdkPixbuf *icon;
    GtkWidget *widget;

    if (GTK_IS_MENU_ITEM (proxy)) {
        g_signal_connect (proxy, "select",
                          G_CALLBACK (menu_item_select_cb), window);
        g_signal_connect (proxy, "deselect",
                          G_CALLBACK (menu_item_deselect_cb), window);


        /* This is a way to easily get pixbufs into the menu items */
        icon = g_object_get_data (G_OBJECT (action), "menu-icon");
        if (icon != NULL) {
            gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy),
                                           gtk_image_new_from_pixbuf (icon));
        }
    }
    if (GTK_IS_TOOL_BUTTON (proxy)) {
        icon = g_object_get_data (G_OBJECT (action), "toolbar-icon");
        if (icon != NULL) {
            widget = gtk_image_new_from_pixbuf (icon);
            gtk_widget_show (widget);
            gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (proxy),
                                             widget);
        }
    }

}
Пример #2
0
/**
 * gtk_tool_button_set_label:
 * @button: a #GtkToolButton
 * @label: (allow-none): a string that will be used as label, or %NULL.
 *
 * Sets @label as the label used for the tool button. The "label" property
 * only has an effect if not overridden by a non-%NULL "label_widget" property.
 * If both the "label_widget" and "label" properties are %NULL, the label
 * is determined by the "stock_id" property. If the "stock_id" property is also
 * %NULL, @button will not have a label.
 * 
 * Since: 2.4
 **/
void
gtk_tool_button_set_label (GtkToolButton *button,
			   const gchar   *label)
{
  gchar *old_label;
  gchar *elided_label;
  AtkObject *accessible;
  
  g_return_if_fail (GTK_IS_TOOL_BUTTON (button));

  old_label = button->priv->label_text;

  button->priv->label_text = g_strdup (label);
  button->priv->contents_invalid = TRUE;     

  if (label)
    {
      elided_label = _gtk_toolbar_elide_underscores (label);
      accessible = gtk_widget_get_accessible (GTK_WIDGET (button->priv->button));
      atk_object_set_name (accessible, elided_label);
      g_free (elided_label);
    }

  g_free (old_label);
 
  g_object_notify (G_OBJECT (button), "label");
}
Пример #3
0
static void ink_toggle_action_update_icon( InkToggleAction* action )
{
    if ( action ) {
        GSList* proxies = gtk_action_get_proxies( GTK_ACTION(action) );
        while ( proxies ) {
            if ( GTK_IS_TOOL_ITEM(proxies->data) ) {
                if ( GTK_IS_TOOL_BUTTON(proxies->data) ) {
                    GtkToolButton* button = GTK_TOOL_BUTTON(proxies->data);

                    GtkWidget* child = sp_icon_new( action->private_data->iconSize, action->private_data->iconId );

#if GTK_CHECK_VERSION(3,0,0)
		    gtk_widget_set_hexpand(child, FALSE);
		    gtk_widget_set_vexpand(child, FALSE);
		    gtk_widget_show_all(child);
		    gtk_tool_button_set_icon_widget(button, child);
#else
                    GtkWidget* align = gtk_alignment_new( 0.5, 0.5, 0.0, 0.0 );
                    gtk_container_add( GTK_CONTAINER(align), child );
                    gtk_widget_show_all( align );
                    gtk_tool_button_set_icon_widget( button, align );
#endif
                }
            }

            proxies = g_slist_next( proxies );
        }
    }
}
Пример #4
0
/**
 * gtk_tool_button_get_label:
 * @button: a #GtkToolButton
 * 
 * Returns the label used by the tool button, or %NULL if the tool button
 * doesn't have a label. or uses a the label from a stock item. The returned
 * string is owned by GTK+, and must not be modified or freed.
 * 
 * Return value: The label, or %NULL
 * 
 * Since: 2.4
 **/
G_CONST_RETURN gchar *
gtk_tool_button_get_label (GtkToolButton *button)
{
  g_return_val_if_fail (GTK_IS_TOOL_BUTTON (button), NULL);

  return button->priv->label_text;
}
Пример #5
0
/**
 * gtk_tool_button_set_icon_widget:
 * @button: a #GtkToolButton
 * @icon_widget: (allow-none): the widget used as icon, or %NULL
 *
 * Sets @icon as the widget used as icon on @button. If @icon_widget is
 * %NULL the icon is determined by the #GtkToolButton:stock-id property. If the
 * #GtkToolButton:stock-id property is also %NULL, @button will not have an icon.
 * 
 * Since: 2.4
 **/
void
gtk_tool_button_set_icon_widget (GtkToolButton *button,
				 GtkWidget     *icon_widget)
{
  g_return_if_fail (GTK_IS_TOOL_BUTTON (button));
  g_return_if_fail (icon_widget == NULL || GTK_IS_WIDGET (icon_widget));

  if (icon_widget != button->priv->icon_widget)
    {
      if (button->priv->icon_widget)
	{
          GtkWidget *parent;

          parent = gtk_widget_get_parent (button->priv->icon_widget);
	  if (parent)
            gtk_container_remove (GTK_CONTAINER (parent),
                                  button->priv->icon_widget);

	  g_object_unref (button->priv->icon_widget);
	}
      
      if (icon_widget)
	g_object_ref_sink (icon_widget);

      button->priv->icon_widget = icon_widget;
      button->priv->contents_invalid = TRUE;
      
      g_object_notify (G_OBJECT (button), "icon-widget");
    }
}
Пример #6
0
/**
 * gtk_tool_button_get_icon_widget:
 * @button: a #GtkToolButton
 * 
 * Return the widget used as icon widget on @button. See
 * gtk_tool_button_set_icon_widget().
 * 
 * Return value: The widget used as icon on @button, or %NULL.
 * 
 * Since: 2.4
 **/
GtkWidget *
gtk_tool_button_get_icon_widget (GtkToolButton *button)
{
  g_return_val_if_fail (GTK_IS_TOOL_BUTTON (button), NULL);

  return button->priv->icon_widget;
}
Пример #7
0
static GtkWidget* ink_toggle_action_create_tool_item( GtkAction* action )
{
    InkToggleAction* act = INK_TOGGLE_ACTION( action );

    GtkWidget* item = GTK_TOGGLE_ACTION_CLASS(ink_toggle_action_parent_class)->parent_class.create_tool_item(action);
    if ( GTK_IS_TOOL_BUTTON(item) ) {
        GtkToolButton* button = GTK_TOOL_BUTTON(item);
        if ( act->private_data->iconId ) {
            GtkWidget* child = sp_icon_new( act->private_data->iconSize, act->private_data->iconId );
            GtkWidget* align = gtk_alignment_new( 0.5, 0.5, 0.0, 0.0 );
            gtk_container_add( GTK_CONTAINER(align), child );
            gtk_tool_button_set_icon_widget( button, align );
        } else {
            gchar *label = 0;
            g_object_get( G_OBJECT(action), "short_label", &label, NULL );
            gtk_tool_button_set_label( button, label );
            g_free( label );
            label = 0;
        }
    } else {
        // For now trigger a warning but don't do anything else
        GtkToolButton* button = GTK_TOOL_BUTTON(item);
        (void)button;
    }
    gtk_widget_show_all( item );

    return item;
}
Пример #8
0
/**
 * gtk_tool_button_get_stock_id:
 * @button: a #GtkToolButton
 * 
 * Returns the name of the stock item. See gtk_tool_button_set_stock_id().
 * The returned string is owned by GTK+ and must not be freed or modifed.
 * 
 * Returns: the name of the stock item for @button.
 * 
 * Since: 2.4
 *
 * Deprecated: 3.10: Use gtk_tool_button_get_icon_name() instead.
 **/
const gchar *
gtk_tool_button_get_stock_id (GtkToolButton *button)
{
  g_return_val_if_fail (GTK_IS_TOOL_BUTTON (button), NULL);

  return button->priv->stock_id;
}
Пример #9
0
static void
glade_gtk_tool_button_set_image_mode (GObject * object, const GValue * value)
{
  GladeWidget *gbutton;

  g_return_if_fail (GTK_IS_TOOL_BUTTON (object));
  gbutton = glade_widget_get_from_gobject (object);

  glade_widget_property_set_sensitive (gbutton, "stock-id", FALSE, NOT_SELECTED_MSG);
  glade_widget_property_set_sensitive (gbutton, "icon-name", FALSE, NOT_SELECTED_MSG);
  glade_widget_property_set_sensitive (gbutton, "icon-widget", FALSE, NOT_SELECTED_MSG);

  switch (g_value_get_int (value))
    {
      case GLADE_TB_MODE_STOCK:
        glade_widget_property_set_sensitive (gbutton, "stock-id", TRUE, NULL);
        break;
      case GLADE_TB_MODE_ICON:
        glade_widget_property_set_sensitive (gbutton, "icon-name", TRUE, NULL);
        break;
      case GLADE_TB_MODE_CUSTOM:
        glade_widget_property_set_sensitive (gbutton, "icon-widget", TRUE, NULL);
        break;
      default:
        break;
    }
}
Пример #10
0
GtkWidget *
_gtk_tool_button_get_button (GtkToolButton *button)
{
  g_return_val_if_fail (GTK_IS_TOOL_BUTTON (button), NULL);

  return button->priv->button;
}
Пример #11
0
/**
 * gtk_tool_button_get_use_underline:
 * @button: a #GtkToolButton
 * 
 * Returns whether underscores in the label property are used as mnemonics
 * on menu items on the overflow menu. See gtk_tool_button_set_use_underline().
 * 
 * Return value: %TRUE if underscores in the label property are used as
 * mnemonics on menu items on the overflow menu.
 * 
 * Since: 2.4
 **/
gboolean
gtk_tool_button_get_use_underline (GtkToolButton *button)
{
  g_return_val_if_fail (GTK_IS_TOOL_BUTTON (button), FALSE);

  return button->priv->use_underline;
}
Пример #12
0
/**
 * gtk_tool_button_set_label_widget:
 * @button: a #GtkToolButton
 * @label_widget: (allow-none): the widget used as label, or %NULL
 *
 * Sets @label_widget as the widget that will be used as the label
 * for @button. If @label_widget is %NULL the "label" property is used
 * as label. If "label" is also %NULL, the label in the stock item
 * determined by the "stock_id" property is used as label. If
 * "stock_id" is also %NULL, @button does not have a label.
 * 
 * Since: 2.4
 **/
void
gtk_tool_button_set_label_widget (GtkToolButton *button,
				  GtkWidget     *label_widget)
{
  g_return_if_fail (GTK_IS_TOOL_BUTTON (button));
  g_return_if_fail (label_widget == NULL || GTK_IS_WIDGET (label_widget));

  if (label_widget != button->priv->label_widget)
    {
      if (button->priv->label_widget)
	{
	  if (button->priv->label_widget->parent)
	    gtk_container_remove (GTK_CONTAINER (button->priv->label_widget->parent),
		    	          button->priv->label_widget);
	  
	  g_object_unref (button->priv->label_widget);
	}
      
      if (label_widget)
	g_object_ref_sink (label_widget);

      button->priv->label_widget = label_widget;
      button->priv->contents_invalid = TRUE;
      
      g_object_notify (G_OBJECT (button), "label-widget");
    }
}
Пример #13
0
static GtkWidget* ink_radio_action_create_tool_item( GtkAction* action )
{
    InkRadioAction* act = INK_RADIO_ACTION( action );
    GtkWidget* item = GTK_RADIO_ACTION_CLASS(ink_radio_action_parent_class)->parent_class.parent_class.create_tool_item(action);

    if ( act->private_data->iconId ) {
        if ( GTK_IS_TOOL_BUTTON(item) ) {
            GtkToolButton* button = GTK_TOOL_BUTTON(item);

            GtkWidget* child = sp_icon_new( act->private_data->iconSize, act->private_data->iconId );
            GtkWidget* align = gtk_alignment_new( 0.5, 0.5, 0.0, 0.0 );
            gtk_container_add( GTK_CONTAINER(align), child );
            gtk_tool_button_set_icon_widget( button, align );
        } else {
            // For now trigger a warning but don't do anything else
            GtkToolButton* button = GTK_TOOL_BUTTON(item);
            (void)button;
        }
    }

    // TODO investigate if needed
    gtk_widget_show_all( item );

    return item;
}
Пример #14
0
/**
 * gtk_tool_button_get_icon_name
 * @button: a #GtkToolButton
 * 
 * Returns the name of the themed icon for the tool button,
 * see gtk_tool_button_set_icon_name().
 *
 * Returns: the icon name or %NULL if the tool button has
 * no themed icon
 * 
 * Since: 2.8
 **/
G_CONST_RETURN gchar*
gtk_tool_button_get_icon_name (GtkToolButton *button)
{
  g_return_val_if_fail (GTK_IS_TOOL_BUTTON (button), NULL);

  return button->priv->icon_name;
}
static GtkWidget *
get_event_widget (GtkWidget *proxy)
{
	GtkWidget *widget;

	/**
	 * Finding the interesting widget requires internal knowledge of
	 * the widgets in question. This can't be helped, but by keeping
	 * the sneaky code in one place, it can easily be updated.
	 */
	if (GTK_IS_MENU_ITEM (proxy)) {
		/* Menu items already forward middle clicks */
		widget = NULL;
	} else if (GTK_IS_MENU_TOOL_BUTTON (proxy)) {
		widget = eel_gtk_menu_tool_button_get_button (GTK_MENU_TOOL_BUTTON (proxy));
	} else if (GTK_IS_TOOL_BUTTON (proxy)) {
		/* The tool button's button is the direct child */
		widget = gtk_bin_get_child (GTK_BIN (proxy));
	} else if (GTK_IS_BUTTON (proxy)) {
		widget = proxy;
	} else {
		/* Don't touch anything we don't know about */
		widget = NULL;
	}

	return widget;
}
Пример #16
0
static void
glade_gtk_tool_button_set_icon_name (GObject * object, const GValue * value)
{
  const gchar *name;

  g_return_if_fail (GTK_IS_TOOL_BUTTON (object));

  name = g_value_get_string (value);

  if (name && strlen (name) == 0)
    name = NULL;

  gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (object), name);
}
Пример #17
0
static void
glade_gtk_tool_button_set_label (GObject * object, const GValue * value)
{
  const gchar *label;

  g_return_if_fail (GTK_IS_TOOL_BUTTON (object));

  label = g_value_get_string (value);

  if (label && strlen (label) == 0)
    label = NULL;

  gtk_tool_button_set_label (GTK_TOOL_BUTTON (object), label);
}
Пример #18
0
static void
glade_gtk_tool_button_set_stock_id (GObject * object, const GValue * value)
{
  const gchar *stock_id;

  g_return_if_fail (GTK_IS_TOOL_BUTTON (object));

  stock_id = g_value_get_string (value);

  if (stock_id && strlen (stock_id) == 0)
    stock_id = NULL;

  gtk_tool_button_set_stock_id (GTK_TOOL_BUTTON (object), stock_id);
}
Пример #19
0
static GtkWidget *
get_actual_button (GtkToolButton *tool_button)
{
	GList *children;
	GtkWidget *button;

	g_return_val_if_fail (GTK_IS_TOOL_BUTTON (tool_button), NULL);

	children = gtk_container_get_children (GTK_CONTAINER (tool_button));
	button = GTK_WIDGET (children->data);

	g_list_free (children);

	return button;
}
Пример #20
0
static void
glade_gtk_tool_button_set_stock_id (GObject * object, const GValue * value)
{
  const gchar *stock_id;

  g_return_if_fail (GTK_IS_TOOL_BUTTON (object));

  stock_id = g_value_get_string (value);

  if (stock_id && strlen (stock_id) == 0)
    stock_id = NULL;

G_GNUC_BEGIN_IGNORE_DEPRECATIONS
  gtk_tool_button_set_stock_id (GTK_TOOL_BUTTON (object), stock_id);
G_GNUC_END_IGNORE_DEPRECATIONS
}
Пример #21
0
/**
 * gtk_tool_button_set_use_underline:
 * @button: a #GtkToolButton
 * @use_underline: whether the button label has the form "_Open"
 *
 * If set, an underline in the label property indicates that the next character
 * should be used for the mnemonic accelerator key in the overflow menu. For
 * example, if the label property is "_Open" and @use_underline is %TRUE,
 * the label on the tool button will be "Open" and the item on the overflow
 * menu will have an underlined 'O'.
 * 
 * Labels shown on tool buttons never have mnemonics on them; this property
 * only affects the menu item on the overflow menu.
 * 
 * Since: 2.4
 **/
void
gtk_tool_button_set_use_underline (GtkToolButton *button,
				   gboolean       use_underline)
{
  g_return_if_fail (GTK_IS_TOOL_BUTTON (button));

  use_underline = use_underline != FALSE;

  if (use_underline != button->priv->use_underline)
    {
      button->priv->use_underline = use_underline;
      button->priv->contents_invalid = TRUE;

      g_object_notify (G_OBJECT (button), "use-underline");
    }
}
Пример #22
0
/**
 * gtk_tool_button_set_stock_id:
 * @button: a #GtkToolButton
 * @stock_id: (allow-none): a name of a stock item, or %NULL
 *
 * Sets the name of the stock item. See gtk_tool_button_new_from_stock().
 * The stock_id property only has an effect if not
 * overridden by non-%NULL "label" and "icon_widget" properties.
 * 
 * Since: 2.4
 **/
void
gtk_tool_button_set_stock_id (GtkToolButton *button,
			      const gchar   *stock_id)
{
  gchar *old_stock_id;
  
  g_return_if_fail (GTK_IS_TOOL_BUTTON (button));

  old_stock_id = button->priv->stock_id;

  button->priv->stock_id = g_strdup (stock_id);
  button->priv->contents_invalid = TRUE;

  g_free (old_stock_id);
  
  g_object_notify (G_OBJECT (button), "stock-id");
}
Пример #23
0
/**
 * gtk_tool_button_set_icon_name
 * @button: a #GtkToolButton
 * @icon_name: (allow-none): the name of the themed icon
 *
 * Sets the icon for the tool button from a named themed icon.
 * See the docs for #GtkIconTheme for more details.
 * The "icon_name" property only has an effect if not
 * overridden by non-%NULL "label", "icon_widget" and "stock_id"
 * properties.
 * 
 * Since: 2.8
 **/
void
gtk_tool_button_set_icon_name (GtkToolButton *button,
			       const gchar   *icon_name)
{
  gchar *old_icon_name;

  g_return_if_fail (GTK_IS_TOOL_BUTTON (button));

  old_icon_name = button->priv->icon_name;

  button->priv->icon_name = g_strdup (icon_name);
  button->priv->contents_invalid = TRUE; 

  g_free (old_icon_name);

  g_object_notify (G_OBJECT (button), "icon-name");
}
static void ink_toggle_action_update_icon( InkToggleAction* action )
{
    if ( action ) {
        GSList* proxies = gtk_action_get_proxies( GTK_ACTION(action) );
        while ( proxies ) {
            if ( GTK_IS_TOOL_ITEM(proxies->data) ) {
                if ( GTK_IS_TOOL_BUTTON(proxies->data) ) {
                    GtkToolButton* button = GTK_TOOL_BUTTON(proxies->data);

                    GtkWidget* child = sp_icon_new( action->private_data->iconSize, action->private_data->iconId );
                    gtk_widget_show_all( child );
                    gtk_tool_button_set_icon_widget( button, child );
                }
            }

            proxies = g_slist_next( proxies );
        }
    }
}
Пример #25
0
GtkToolItem* AbstractToolItem::createItem(bool horizontal)
{
	XOJ_CHECK_TYPE(AbstractToolItem);

	if (this->item)
	{
		return this->item;
	}

	this->item = createTmpItem(horizontal);
	g_object_ref(this->item);

	if (GTK_IS_TOOL_BUTTON(this->item) || GTK_IS_TOGGLE_TOOL_BUTTON(this->item))
	{
		g_signal_connect(this->item, "clicked", G_CALLBACK(&toolButtonCallback), this);
	}

	return this->item;
}
Пример #26
0
static void
connect_proxy (GtkAction *action,
               GtkWidget *proxy)
{
        GtkToolButton *tool;
        GtkWidget *button;

	if (GTK_IS_TOOL_BUTTON (proxy)) {
                tool = GTK_TOOL_BUTTON (proxy);
                button = get_actual_button (tool);

                g_signal_connect (button, "button-press-event",
                                  G_CALLBACK (tool_button_press_cb), action);
                g_signal_connect (button, "button-release-event",
                                  G_CALLBACK (tool_button_release_cb), action);
        }

	(* GTK_ACTION_CLASS (nemo_navigation_action_parent_class)->connect_proxy) (action, proxy);
}
Пример #27
0
// Connect the given menuitem or toolbutton to this Statement
void Statement::connectWidget(GtkWidget* widget) {
	if (GTK_IS_MENU_ITEM(widget)) {
		// Connect the static callback function and pass the pointer to this class
		gulong handler = g_signal_connect(G_OBJECT(widget), "activate", G_CALLBACK(onMenuItemClicked), this);

		_connectedWidgets[widget] = handler;
	}
	else if (GTK_IS_TOOL_BUTTON(widget)) {
		// Connect the static callback function and pass the pointer to this class
		gulong handler = g_signal_connect(G_OBJECT(widget), "clicked", G_CALLBACK(onToolButtonPress), this);

		_connectedWidgets[widget] = handler;
	}
	else if (GTK_IS_BUTTON(widget)) {
		// Connect the static callback function and pass the pointer to this class
		gulong handler = g_signal_connect(G_OBJECT(widget), "clicked", G_CALLBACK(onButtonPress), this);

		_connectedWidgets[widget] = handler;
	}
}
Пример #28
0
static void
glade_gtk_tool_button_set_custom_label (GObject * object, const GValue * value)
{
  GladeWidget *gbutton;

  g_return_if_fail (GTK_IS_TOOL_BUTTON (object));
  gbutton = glade_widget_get_from_gobject (object);

  glade_widget_property_set_sensitive (gbutton, "label", FALSE, NOT_SELECTED_MSG);
  glade_widget_property_set_sensitive (gbutton, "label-widget", FALSE, NOT_SELECTED_MSG);
  glade_widget_property_set_sensitive (gbutton, "use-underline", FALSE,
                                       _("This property only applies when configuring the label with text"));

  if (g_value_get_boolean (value))
    glade_widget_property_set_sensitive (gbutton, "label-widget", TRUE, NULL);
  else
    {
      glade_widget_property_set_sensitive (gbutton, "label", TRUE, NULL);
      glade_widget_property_set_sensitive (gbutton, "use-underline", TRUE, NULL);
    }
}
Пример #29
0
static void
disconnect_proxy (GtkAction *action,
                  GtkWidget *proxy)
{
        GtkToolButton *tool;
        GtkWidget *button;

	if (GTK_IS_TOOL_BUTTON (proxy)) {
                tool = GTK_TOOL_BUTTON (proxy);
                button = get_actual_button (tool);

                /* remove any possible timeout going on */
                unschedule_menu_popup_timeout (NEMO_NAVIGATION_ACTION (action));

		g_signal_handlers_disconnect_by_func (button,
                                                      G_CALLBACK (tool_button_press_cb), action);
		g_signal_handlers_disconnect_by_func (button,
                                                      G_CALLBACK (tool_button_release_cb), action);
	}

	(* GTK_ACTION_CLASS (nemo_navigation_action_parent_class)->disconnect_proxy) (action, proxy);
}
Пример #30
0
static GtkWidget* ink_action_create_tool_item( GtkAction* action )
{
    InkAction* act = INK_ACTION( action );
    GtkWidget* item = GTK_ACTION_CLASS(ink_action_parent_class)->create_tool_item(action);

    if ( act->private_data->iconId ) {
        if ( GTK_IS_TOOL_BUTTON(item) ) {
            GtkToolButton* button = GTK_TOOL_BUTTON(item);

            GtkWidget* child = sp_icon_new( act->private_data->iconSize, act->private_data->iconId );
            gtk_tool_button_set_icon_widget( button, child );
        } else {
            // For now trigger a warning but don't do anything else
            GtkToolButton* button = GTK_TOOL_BUTTON(item);
            (void)button;
        }
    }

    // TODO investigate if needed
    gtk_widget_show_all( item );

    return item;
}