Exemplo n.º 1
0
static void serializer_visit (Serializer* self, GtkWidget* widget) {
    g_return_if_fail (self != NULL);
    g_return_if_fail (widget != NULL);
    if (GTK_IS_MENU_BAR (widget)) {
        GtkWidget* _tmp0_;
        serializer_visit_menubar (self, (_tmp0_ = widget, GTK_IS_MENU_BAR (_tmp0_) ? ((GtkMenuBar*) _tmp0_) : NULL));
    } else {
        if (GTK_IS_MENU (widget)) {
            GtkWidget* _tmp1_;
            serializer_visit_menu (self, (_tmp1_ = widget, GTK_IS_MENU (_tmp1_) ? ((GtkMenu*) _tmp1_) : NULL));
        } else {
            if (GTK_IS_MENU_ITEM (widget)) {
                GtkWidget* _tmp2_;
                serializer_visit_menuitem (self, (_tmp2_ = widget, GTK_IS_MENU_ITEM (_tmp2_) ? ((GtkMenuItem*) _tmp2_) : NULL));
            } else {
                if (GTK_IS_LABEL (widget)) {
                    GtkWidget* _tmp3_;
                    serializer_visit_label (self, (_tmp3_ = widget, GTK_IS_LABEL (_tmp3_) ? ((GtkLabel*) _tmp3_) : NULL));
                } else {
                    if (GTK_IS_IMAGE (widget)) {
                        GtkWidget* _tmp4_;
                        serializer_visit_image (self, (_tmp4_ = widget, GTK_IS_IMAGE (_tmp4_) ? ((GtkImage*) _tmp4_) : NULL));
                    } else {
                        if (GTK_IS_CONTAINER (widget)) {
                            GtkWidget* _tmp5_;
                            serializer_visit_container (self, (_tmp5_ = widget, GTK_IS_CONTAINER (_tmp5_) ? ((GtkContainer*) _tmp5_) : NULL));
                        }
                    }
                }
            }
        }
    }
}
static void
gb_view_source_lang_activate (GbViewSource *source,
                              GtkMenuItem  *menu_item)
{
    GbViewSourcePrivate *priv;
    GtkSourceLanguageManager *lm;
    GtkSourceLanguage *lang;
    const gchar *lang_id;

    ENTRY;

    g_return_if_fail(GB_IS_VIEW_SOURCE(source));
    g_return_if_fail(GTK_IS_MENU_ITEM(menu_item));

    priv = source->priv;

    if ((lang_id = g_object_get_data(G_OBJECT(menu_item), "language-id"))) {
        lm = gtk_source_language_manager_get_default();
        lang = gtk_source_language_manager_get_language(lm, lang_id);
        gtk_source_buffer_set_language(priv->buffer, lang);
        gb_menu_button_set_label(GB_MENU_BUTTON(priv->lang_combo),
                                 gtk_source_language_get_name(lang));
    }

    EXIT;
}
Exemplo n.º 3
0
static void account_item_activated_cb(GtkMenuItem *menuitem, gpointer user_data)
{
    //IndicatorFitbit *self = INDICATOR_FITBIT(user_data);

    g_return_if_fail(GTK_IS_MENU_ITEM(menuitem));
    g_return_if_fail(IS_INDICATOR_FITBIT(user_data));
}
Exemplo n.º 4
0
static gboolean
gail_menu_shell_add_selection (AtkSelection *selection,
                               gint          i)
{
  GtkMenuShell *shell;
  GList *item;
  guint length;
  GtkWidget *widget;

  widget =  GTK_ACCESSIBLE (selection)->widget;
  if (widget == NULL)
  {
    /* State is defunct */
    return FALSE;
  }

  shell = GTK_MENU_SHELL (widget);
  length = g_list_length (shell->children);
  if (i < 0 || i > length)
    return FALSE;

  item = g_list_nth (shell->children, i);
  g_return_val_if_fail (item != NULL, FALSE);
  g_return_val_if_fail (GTK_IS_MENU_ITEM(item->data), FALSE);
   
  gtk_menu_shell_select_item (shell, GTK_WIDGET (item->data));
  return TRUE;
}
static void
gb_view_source_tab_size_activate (GtkMenuItem  *menu_item,
                                  GbViewSource *source)
{
    GbViewSourcePrivate *priv;
    const gchar *label;
    gint size;

    ENTRY;

    g_return_if_fail(GTK_IS_MENU_ITEM(menu_item));
    g_return_if_fail(GB_IS_VIEW_SOURCE(source));

    priv = source->priv;

    label = gtk_menu_item_get_label(menu_item);
    size = g_ascii_strtoll(label, NULL, 10);

    if (size > 0) {
        gtk_source_view_set_tab_width(GTK_SOURCE_VIEW(priv->source1), size);
        if (priv->source2) {
            gtk_source_view_set_tab_width(GTK_SOURCE_VIEW(priv->source2), size);
        }
        g_object_set(priv->size_combo,
                     "label", label,
                     NULL);
    }

    EXIT;
}
Exemplo n.º 6
0
static AtkStateSet *
gtk_menu_item_accessible_ref_state_set (AtkObject *obj)
{
  AtkObject *menu_item;
  AtkStateSet *state_set, *parent_state_set;

  state_set = ATK_OBJECT_CLASS (_gtk_menu_item_accessible_parent_class)->ref_state_set (obj);

  menu_item = atk_object_get_parent (obj);

  if (menu_item)
    {
      if (!GTK_IS_MENU_ITEM (gtk_accessible_get_widget (GTK_ACCESSIBLE (menu_item))))
        return state_set;

      parent_state_set = atk_object_ref_state_set (menu_item);
      if (!atk_state_set_contains_state (parent_state_set, ATK_STATE_SELECTED))
        {
          atk_state_set_remove_state (state_set, ATK_STATE_FOCUSED);
          atk_state_set_remove_state (state_set, ATK_STATE_SHOWING);
        }
      g_object_unref (parent_state_set);
    }

  return state_set;
}
Exemplo n.º 7
0
static void
gwy_sensitivity_group_debug(GwySensitivityGroup *sensgroup)
{
    SensList *senslist;
    GtkWidget *widget, *w;
    GList *l, *ll;
    const gchar *s;
    gint nw = 0;

    g_printerr("SENS GROUP %p\n", sensgroup);
    for (ll = sensgroup->lists; ll; ll = g_list_next(ll)) {
        g_printerr("    LIST: ");
        senslist = (SensList*)ll->data;
        g_printerr("mask=%04x, dirty=%d, parent=%p\n",
                   senslist->mask, senslist->dirty, senslist->parent);
        for (l = senslist->widgets; l; l = g_list_next(l)) {
            nw++;
            g_printerr("        WIDGET: ");
            widget = GTK_WIDGET(l->data);
            g_printerr("%s ", g_type_name(G_TYPE_FROM_INSTANCE(widget)));
            if (GTK_IS_BUTTON(widget)) {
                s = gtk_button_get_label(GTK_BUTTON(widget));
                if (s)
                    g_printerr("<%s> ", s);
                else {
                    w = gtk_bin_get_child(GTK_BIN(widget));
                    if (w) {
                        g_printerr("%s ", g_type_name(G_TYPE_FROM_INSTANCE(w)));
                        if (GTK_IS_LABEL(w)) {
                            s = gtk_label_get_text(GTK_LABEL(w));
                            if (s)
                                g_printerr("<%s> ", s);
                        }
                        else if (GTK_IS_IMAGE(w)) {
                            s = NULL;
                            gtk_image_get_stock(GTK_IMAGE(w), (gchar**)&s,
                                                NULL);
                            if (s)
                                g_printerr("<%s> ", s);
                        }
                    }
                }
            }
            else if (GTK_IS_MENU_ITEM(widget)) {
                w = gtk_bin_get_child(GTK_BIN(widget));
                if (w) {
                    g_printerr("%s ", g_type_name(G_TYPE_FROM_INSTANCE(w)));
                    if (GTK_IS_LABEL(w)) {
                        s = gtk_label_get_text(GTK_LABEL(w));
                        if (s)
                            g_printerr("<%s> ", s);
                    }
                }
            }
            g_printerr("\n");
        }
    }
    g_printerr("    nwidgets=%d, ref_count=%d\n",
               nw, G_OBJECT(sensgroup)->ref_count);
}
Exemplo n.º 8
0
/**
 * gtk_tool_item_set_proxy_menu_item:
 * @tool_item: a #GtkToolItem
 * @menu_item_id: a string used to identify @menu_item
 * @menu_item: a #GtkMenuItem to be used in the overflow menu
 *
 * Sets the #GtkMenuItem used in the toolbar overflow menu. The
 * @menu_item_id is used to identify the caller of this function and
 * should also be used with gtk_tool_item_get_proxy_menu_item().
 *
 * Since: 2.4
 **/
void
gtk_tool_item_set_proxy_menu_item (GtkToolItem *tool_item,
                                   const gchar *menu_item_id,
                                   GtkWidget   *menu_item)
{
    g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
    g_return_if_fail (menu_item == NULL || GTK_IS_MENU_ITEM (menu_item));
    g_return_if_fail (menu_item_id != NULL);

    g_free (tool_item->priv->menu_item_id);

    tool_item->priv->menu_item_id = g_strdup (menu_item_id);

    if (tool_item->priv->menu_item != menu_item)
    {
        if (tool_item->priv->menu_item)
            g_object_unref (tool_item->priv->menu_item);

        if (menu_item)
        {
            g_object_ref_sink (menu_item);

            gtk_widget_set_sensitive (menu_item,
                                      gtk_widget_get_sensitive (GTK_WIDGET (tool_item)));
        }

        tool_item->priv->menu_item = menu_item;
    }
}
Exemplo n.º 9
0
static void
mail_browser_connect_proxy_cb (EMailBrowser *browser,
                               GtkAction *action,
                               GtkWidget *proxy)
{
	GtkStatusbar *statusbar;
	guint context_id;

	if (!GTK_IS_MENU_ITEM (proxy))
		return;

	statusbar = GTK_STATUSBAR (browser->priv->statusbar);
	context_id = gtk_statusbar_get_context_id (statusbar, G_STRFUNC);

	g_object_set_data (
		G_OBJECT (proxy), "context-id",
		GUINT_TO_POINTER (context_id));

	g_signal_connect_swapped (
		proxy, "select",
		G_CALLBACK (mail_browser_menu_item_select_cb), browser);

	g_signal_connect_swapped (
		proxy, "deselect",
		G_CALLBACK (mail_browser_menu_item_deselect_cb), browser);
}
Exemplo n.º 10
0
static gboolean
gtk_menu_item_accessible_add_selection (AtkSelection *selection,
                                           gint          i)
{
  GtkMenuShell *shell;
  GList *kids;
  guint length;
  GtkWidget *widget;
  GtkWidget *menu;
  GtkWidget *child;

  widget =  gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
  if (widget == NULL)
    return FALSE;

  menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (widget));
  if (menu == NULL)
    return FALSE;

  shell = GTK_MENU_SHELL (menu);
  kids = gtk_container_get_children (GTK_CONTAINER (shell));
  length = g_list_length (kids);
  if (i < 0 || i > length)
    {
      g_list_free (kids);
      return FALSE;
    }

  child = g_list_nth_data (kids, i);
  g_list_free (kids);
  g_return_val_if_fail (GTK_IS_MENU_ITEM (child), FALSE);
  gtk_menu_shell_select_item (shell, GTK_WIDGET (child));
  return TRUE;
}
Exemplo n.º 11
0
static gboolean
qtcMenuShellLeave(GtkWidget *widget, GdkEventCrossing *event, void *data)
{
    QTC_UNUSED(data);
    QTC_UNUSED(event);
    if (GTK_IS_MENU_SHELL(widget) && GTK_IS_CONTAINER(widget)) {
        GList *children = gtk_container_get_children(GTK_CONTAINER(widget));
        for (GList *child = children;child;child = g_list_next(child)) {
            if ((child->data) && GTK_IS_MENU_ITEM(child->data) &&
                (gtk_widget_get_state(GTK_WIDGET(child->data)) !=
                 GTK_STATE_INSENSITIVE)) {
                GtkWidget *submenu =
                    gtk_menu_item_get_submenu(GTK_MENU_ITEM(child->data));
                GtkWidget *topLevel =
                    submenu ? gtk_widget_get_toplevel(submenu) : NULL;

                if (submenu &&
                    ((!GTK_IS_MENU(submenu)) ||
                     (!(gtk_widget_get_realized(submenu) &&
                        gtk_widget_get_visible(submenu) &&
                        gtk_widget_get_realized(topLevel) &&
                        gtk_widget_get_visible(topLevel))))) {
                    gtk_widget_set_state(GTK_WIDGET(child->data),
                                         GTK_STATE_NORMAL);
                }
            }
        }
        if (children) {
            g_list_free(children);
        }
    }
    return false;
}
Exemplo n.º 12
0
static void
menu_choice_activate (GtkWidget *item,
		      gpointer   data)
{
  gpointer udata = gtk_object_get_user_data (GTK_OBJECT (item));
  
  if (GTK_IS_MENU (current_popup_menu))
    {
      gtk_object_set_data (GTK_OBJECT (current_popup_menu), "BstChoice", udata);
      
      if (modal_loop_quit_on_menu_item_activate)
	modal_loop_running = FALSE;
    }
  else	/* current_popup_menu is not set e.g. for option menus */
    {
      while (GTK_IS_MENU (item->parent))
	{
	  GtkWidget *tmp;
          
	  item = item->parent;
	  tmp = gtk_menu_get_attach_widget (GTK_MENU (item));
	  if (GTK_IS_MENU_ITEM (tmp))
	    item = tmp;
	}
      g_assert (GTK_IS_MENU (item));
      
      gtk_object_set_data (GTK_OBJECT (item), "BstChoice", udata);
    }
}
Exemplo n.º 13
0
/*****************************************************************************
 * Useful function to retrieve p_intf
 ****************************************************************************/
void * E_(__GtkGetIntf)( GtkWidget * widget )
{
    void *p_data;

    if( GTK_IS_MENU_ITEM( widget ) )
    {
        /* Look for a GTK_MENU */
        while( widget->parent && !GTK_IS_MENU( widget ) )
        {
            widget = widget->parent;
        }

        /* Maybe this one has the data */
        p_data = gtk_object_get_data( GTK_OBJECT( widget ), "p_intf" );
        if( p_data )
        {
            return p_data;
        }

        /* Otherwise, the parent widget has it */
        widget = gtk_menu_get_attach_widget( GTK_MENU( widget ) );
    }

    /* We look for the top widget */
    widget = gtk_widget_get_toplevel( GTK_WIDGET( widget ) );

    p_data = gtk_object_get_data( GTK_OBJECT( widget ), "p_intf" );

    return p_data;
}
Exemplo n.º 14
0
static void
disconnect_proxy_cb (GtkUIManager *manager,
                     GtkAction *action,
                     GtkWidget *proxy,
                     CajaWindow *window)
{
    GtkWidget *widget;

    if (GTK_IS_MENU_ITEM (proxy))
    {
        g_signal_handlers_disconnect_by_func
        (proxy, G_CALLBACK (menu_item_select_cb), window);
        g_signal_handlers_disconnect_by_func
        (proxy, G_CALLBACK (menu_item_deselect_cb), window);
    }

    widget = get_event_widget (proxy);
    if (widget)
    {
        g_signal_handlers_disconnect_by_func (widget,
                                              G_CALLBACK (proxy_button_press_event_cb),
                                              action);
        g_signal_handlers_disconnect_by_func (widget,
                                              G_CALLBACK (proxy_button_release_event_cb),
                                              action);
    }

}
Exemplo n.º 15
0
PanelWidget *
menu_get_panel (GtkWidget *menu)
{
	PanelWidget *retval = NULL;

	g_return_val_if_fail (menu != NULL, NULL);

	if (GTK_IS_MENU_ITEM (menu))
		menu = gtk_widget_get_parent (menu);

	g_return_val_if_fail (GTK_IS_MENU (menu), NULL);

	while (menu) {
		retval = g_object_get_data (G_OBJECT (menu), "menu_panel");
		if (retval)
			break;

		menu = gtk_widget_get_parent (gtk_menu_get_attach_widget (GTK_MENU (menu)));
		if (!GTK_IS_MENU (menu))
			break;
	}

	if (retval && !PANEL_IS_WIDGET (retval)) {
		g_warning ("Invalid PanelWidget associated with menu");
		retval = NULL;
	}

	if (!retval) {
		g_warning ("Cannot find the PanelWidget associated with menu");
		retval = panels->data;
	}

	return retval;
}
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;
}
static void
connect_proxy_cb (GtkActionGroup *action_group,
                  GtkAction *action,
                  GtkWidget *proxy,
                  gpointer dummy)
{
	GtkLabel *label;
	GIcon *icon;

	if (!GTK_IS_MENU_ITEM (proxy))
		return;

	label = GTK_LABEL (gtk_bin_get_child (GTK_BIN (proxy)));

	gtk_label_set_use_underline (label, FALSE);
	gtk_label_set_ellipsize (label, PANGO_ELLIPSIZE_END);
	gtk_label_set_max_width_chars (label, MENU_ITEM_MAX_WIDTH_CHARS);

	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_gicon (icon, GTK_ICON_SIZE_MENU));
	}
}
Exemplo n.º 18
0
static gint
menu_item_remove_gtk (GtkContainer *container,
                      GtkWidget    *widget)
{
  GtkWidget *parent_widget;
  AtkObject *atk_parent;
  AtkObject *atk_child;
  GtkContainerAccessible *container_accessible;
  gint index;
  gint list_length;

  g_return_val_if_fail (GTK_IS_MENU (container), 1);

  parent_widget = gtk_menu_get_attach_widget (GTK_MENU (container));
  if (GTK_IS_MENU_ITEM (parent_widget))
    {
      atk_parent = gtk_widget_get_accessible (parent_widget);
      atk_child = gtk_widget_get_accessible (widget);

      g_object_notify (G_OBJECT (atk_child), "accessible-parent");

      container_accessible = GTK_CONTAINER_ACCESSIBLE (atk_parent);
      index = g_list_index (container_accessible->children, widget);
      list_length = g_list_length (container_accessible->children);
      g_list_free (container_accessible->children);
      container_accessible->children = gtk_container_get_children (container);
      if (index >= 0 && index <= list_length)
        g_signal_emit_by_name (atk_parent, "children-changed::remove",
                               index, atk_child, NULL);
    }
  return 1;
}
Exemplo n.º 19
0
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);
        }
    }

}
Exemplo n.º 20
0
static gboolean
gail_menu_shell_add_selection (AtkSelection *selection,
                               gint          i)
{
  GList *kids;
  GtkWidget *item;
  guint length;
  GtkWidget *widget;

  widget =  gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
  if (widget == NULL)
  {
    /* State is defunct */
    return FALSE;
  }

  kids = gtk_container_get_children (GTK_CONTAINER (widget));
  length = g_list_length (kids);
  if (i < 0 || i > length)
    {
      g_list_free (kids);
      return FALSE;
    }

  item = g_list_nth_data (kids, i);
  g_list_free (kids);
  g_return_val_if_fail (GTK_IS_MENU_ITEM(item), FALSE);
  gtk_menu_shell_select_item (GTK_MENU_SHELL (widget), item);
  return TRUE;
}
Exemplo n.º 21
0
/**
 * _gtk_action_sync_menu_visible:
 * @action: (allow-none): a #GtkAction, or %NULL to determine the action from @proxy
 * @proxy: a proxy menu item
 * @empty: whether the submenu attached to @proxy is empty
 * 
 * Updates the visibility of @proxy from the visibility of @action
 * according to the following rules:
 * <itemizedlist>
 * <listitem><para>if @action is invisible, @proxy is too
 * </para></listitem>
 * <listitem><para>if @empty is %TRUE, hide @proxy unless the "hide-if-empty" 
 *   property of @action indicates otherwise
 * </para></listitem>
 * </itemizedlist>
 * 
 * This function is used in the implementation of #GtkUIManager.
 **/
void
_gtk_action_sync_menu_visible (GtkAction *action,
			       GtkWidget *proxy,
			       gboolean   empty)
{
  gboolean visible = TRUE;
  gboolean hide_if_empty = TRUE;

  g_return_if_fail (GTK_IS_MENU_ITEM (proxy));
  g_return_if_fail (action == NULL || GTK_IS_ACTION (action));

  if (action == NULL)
    action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (proxy));

  if (action)
    {
      /* a GtkMenu for a <popup/> doesn't have to have an action */
      visible = gtk_action_is_visible (action);
      hide_if_empty = action->private_data->hide_if_empty;
    }

  if (visible && !(empty && hide_if_empty))
    gtk_widget_show (proxy);
  else
    gtk_widget_hide (proxy);
}
void init_clock_indicator(void)
{
    if(!config.clock.enabled)
    {
        gtk_widget_hide(greeter.ui.clock.time_box);
        return;
    }

    if(config.clock.calendar && GTK_IS_MENU_SHELL(greeter.ui.clock.time_menu))
    {
        GtkWidget* calendar_menuitem = NULL;

        #ifdef CLOCK_USE_IDO_CALENDAR
        calendar_menuitem = ido_calendar_menu_item_new();
        greeter.ui.clock.calendar_widget = ido_calendar_menu_item_get_calendar(IDO_CALENDAR_MENU_ITEM(calendar_menuitem));
        #else
        calendar_menuitem = create_simple_calendar_item(&greeter.ui.clock.calendar_widget);
        #endif

        if(!greeter.ui.clock.date_widget)
            greeter.ui.clock.date_widget = gtk_menu_item_new_with_label("");
        gtk_menu_shell_append(GTK_MENU_SHELL(greeter.ui.clock.time_menu), greeter.ui.clock.date_widget);
        gtk_menu_shell_append(GTK_MENU_SHELL(greeter.ui.clock.time_menu), calendar_menuitem);

        gtk_widget_add_events(greeter.ui.clock.date_widget, GDK_VISIBILITY_NOTIFY_MASK);
        visibility_notify_id = g_signal_connect(greeter.ui.clock.date_widget,
                                                "visibility-notify-event",
                                                G_CALLBACK(on_visibility_notify),
                                                NULL);

        gtk_widget_show_all(greeter.ui.clock.time_menu);
        if(GTK_IS_MENU_ITEM(greeter.ui.clock.time_widget))
            gtk_menu_item_set_submenu(GTK_MENU_ITEM(greeter.ui.clock.time_widget), greeter.ui.clock.time_menu);
    }
    else if(GTK_IS_MENU_ITEM(greeter.ui.clock.time_widget))
        gtk_menu_item_set_submenu(GTK_MENU_ITEM(greeter.ui.clock.time_widget), NULL);
    else
        gtk_widget_hide(greeter.ui.clock.time_menu);

    if(greeter.ui.clock.time_widget)
    {
        clock_handler(NULL);
        g_timeout_add_seconds(1, (GSourceFunc)clock_handler, (gpointer)TRUE);
        gtk_widget_show(greeter.ui.clock.time_widget);
    }
}
Exemplo n.º 23
0
static bool
childrenUseEvent(GtkWidget *widget, GdkEventButton *event, bool inNoteBook)
{
    // accept, by default
    bool usable = true;

    // get children and check
    GList *children = gtk_container_get_children(GTK_CONTAINER(widget));
    for (GList *child = children;child && usable;child = g_list_next(child)) {
        // cast child to GtkWidget
        if (GTK_IS_WIDGET(child->data)) {
            GtkWidget *childWidget = GTK_WIDGET(child->data);
            GdkWindow *window = nullptr;

            // check widget state and type
            if (gtk_widget_get_state(childWidget) == GTK_STATE_PRELIGHT) {
                // if widget is prelight, we don't need to check where event
                // happen, any prelight widget indicate we can't do a move
                usable = false;
                continue;
            }

            window = gtk_widget_get_window(childWidget);
            if (!(window && gdk_window_is_visible(window)))
                continue;

            if (GTK_IS_NOTEBOOK(childWidget))
                inNoteBook = true;

            if(!(event && withinWidget(childWidget, event)))
                continue;

            // check special cases for which grab should not be enabled
            if((isBlackListed(G_OBJECT(childWidget))) ||
               (GTK_IS_NOTEBOOK(widget) && Tab::isLabel(GTK_NOTEBOOK(widget),
                                                         childWidget)) ||
               (GTK_IS_BUTTON(childWidget) &&
                gtk_widget_get_state(childWidget) != GTK_STATE_INSENSITIVE) ||
               (gtk_widget_get_events(childWidget) &
                (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK)) ||
               (GTK_IS_MENU_ITEM(childWidget)) ||
               (GTK_IS_SCROLLED_WINDOW(childWidget) &&
                (!inNoteBook || gtk_widget_is_focus(childWidget)))) {
                usable = false;
            }

            // if child is a container and event has been accepted so far,
            // also check it, recursively
            if (usable && GTK_IS_CONTAINER(childWidget)) {
                usable = childrenUseEvent(childWidget, event, inNoteBook);
            }
        }
    }
    if (children) {
        g_list_free(children);
    }
    return usable;
}
Exemplo n.º 24
0
void
glade_gtk_menu_item_remove_child (GladeWidgetAdaptor * adaptor,
                                  GObject * object, GObject * child)
{
  g_return_if_fail (GTK_IS_MENU_ITEM (object));
  g_return_if_fail (GTK_IS_MENU (child));

  g_object_set_data (child, "special-child-type", NULL);

  gtk_menu_item_set_submenu (GTK_MENU_ITEM (object), NULL);
}
Exemplo n.º 25
0
static void
gam_app_ui_disconnect_proxy_cb (GtkUIManager *manager, GtkAction *action,
                                GtkWidget    *proxy,   GamApp    *gam_app)
{
    if (GTK_IS_MENU_ITEM (proxy)) {
        g_signal_handlers_disconnect_by_func (G_OBJECT (proxy),
            G_CALLBACK (gam_app_menu_item_select_cb), gam_app);
        g_signal_handlers_disconnect_by_func (G_OBJECT (proxy),
            G_CALLBACK (gam_app_menu_item_deselect_cb), gam_app);
    }
}
Exemplo n.º 26
0
Arquivo: menu.c Projeto: CBke/xfwm4
GtkWidget *
menu_item_connect (GtkWidget * item, MenuData * item_data)
{
    TRACE ("entering menu_item_connect");
    g_return_val_if_fail (item != NULL, NULL);
    g_return_val_if_fail (GTK_IS_MENU_ITEM (item), NULL);
    g_signal_connect_closure (GTK_OBJECT (item), "activate",
        g_cclosure_new (GTK_SIGNAL_FUNC (activate_cb), item_data,
            (GClosureNotify) closure_notify), FALSE);
    return (item);
}
Exemplo n.º 27
0
static void
proxy_set_use_underline (GtkWidget *proxy,
                         gboolean   use_underline)
{
    g_return_if_fail (GTK_IS_WIDGET (proxy));

    if (GTK_IS_MENU_ITEM (proxy) && GTK_BIN (proxy)->child && GTK_IS_LABEL (GTK_BIN (proxy)->child))
        gtk_label_set_use_underline (GTK_LABEL (GTK_BIN (proxy)->child), use_underline);
    else if (GTK_IS_BUTTON (proxy))
        gtk_button_set_use_underline (GTK_BUTTON (proxy), use_underline);
}
Exemplo n.º 28
0
static gboolean
parent_set_emission_hook (GSignalInvocationHint *ihint,
			  guint                  n_param_values,
			  const GValue          *param_values,
			  gpointer               data)
{
  GtkWidget *instance = g_value_get_object (param_values);

  if (GTK_IS_MENU_ITEM (instance))
    {
      GtkWidget *previous_parent = g_value_get_object (param_values + 1);
      GtkWidget *menu_shell      = NULL;

      if (GTK_IS_MENU_SHELL (previous_parent))
	{
	  menu_shell = previous_parent;
        }
      else
      {
        GtkWidget *parent;

        parent = gtk_widget_get_parent (instance);

        if (GTK_IS_MENU_SHELL (parent))
	  {
	    menu_shell = parent;
	  }
      }

      if (menu_shell)
        {
	  CarbonMenu *carbon_menu = carbon_menu_get (menu_shell);

	  if (carbon_menu)
	    {
#if 0
	      g_printerr ("%s: item %s %p (%s, %s)\n", G_STRFUNC,
			  previous_parent ? "removed from" : "added to",
			  menu_shell,
			  get_menu_label_text (instance, NULL),
			  g_type_name (G_TYPE_FROM_INSTANCE (instance)));
#endif

	      sync_menu_shell (GTK_MENU_SHELL (menu_shell),
			       carbon_menu->menu,
			       carbon_menu->toplevel,
			       FALSE);
	    }
        }
    }

  return TRUE;
}
Exemplo n.º 29
0
static void
on_ui_proxy_disconnected (GtkUIManager *ui, GtkAction *action,
	GtkWidget *proxy, LdWindowMain *window)
{
	if (GTK_IS_MENU_ITEM (proxy))
	{
		g_signal_handlers_disconnect_by_func
			(proxy, G_CALLBACK (on_menu_item_selected), window);
		g_signal_handlers_disconnect_by_func
			(proxy, G_CALLBACK (on_menu_item_deselected), window);
	}
}
Exemplo n.º 30
0
static void
activate_back_or_forward_menu_item (GtkMenuItem *menu_item, 
				    NemoWindow *window,
				    gboolean back)
{
	int index;
	
	g_assert (GTK_IS_MENU_ITEM (menu_item));

	index = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menu_item), "user_data"));

	nemo_window_back_or_forward (window, back, index, should_open_in_new_tab ());
}