Esempio n. 1
0
static gboolean window_menu_key_press_event(GtkWidget* widget, GdkEventKey* event, WindowMenu* window_menu)
{
	GtkMenuShell* menu_shell;
	WnckSelector* selector;

	switch (event->keyval)
	{
		case GDK_KEY_KP_Enter:
		case GDK_KEY_ISO_Enter:
		case GDK_KEY_3270_Enter:
		case GDK_KEY_Return:
		case GDK_KEY_space:
		case GDK_KEY_KP_Space:
			selector = WNCK_SELECTOR(window_menu->selector);
			/*
			 * We need to call _gtk_menu_shell_activate() here as is done in
			 * window_key_press_handler in gtkmenubar.c which pops up menu
			 * when F10 is pressed.
			 *
			 * As that function is private its code is replicated here.
			 */
			menu_shell = GTK_MENU_SHELL(selector);

			gtk_menu_shell_select_first(menu_shell, FALSE);
			return TRUE;
		default:
			break;
	}

	return FALSE;
}
Esempio n. 2
0
static void
gtk_menu_button_clicked (GtkButton *button)
{
  GtkMenuButton *menu_button = GTK_MENU_BUTTON (button);
  GtkMenuButtonPrivate *priv = menu_button->priv;
  gboolean active = TRUE;

  if (priv->menu && !gtk_widget_get_visible (priv->menu))
    {
      GdkEvent *event;

      event = gtk_get_current_event ();

      popup_menu (menu_button,
                  (event && event->type != GDK_BUTTON_RELEASE) ?
                  (GdkEventButton *) event : NULL);

      if (!event ||
          event->type == GDK_KEY_PRESS ||
          event->type == GDK_KEY_RELEASE)
        gtk_menu_shell_select_first (GTK_MENU_SHELL (priv->menu), FALSE);

      if (event)
        gdk_event_free (event);
    }
  else if (priv->popover && !gtk_widget_get_visible (priv->popover))
    gtk_widget_show (priv->popover);
  else
    active = FALSE;

  GTK_BUTTON_CLASS (gtk_menu_button_parent_class)->clicked (button);

  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), active);
  gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (button));
}
Esempio n. 3
0
static void
hippo_status_icon_popup_menu(GtkStatusIcon *gtk_icon,
                             guint          button,
                             guint32        activate_time)
{
    HippoStatusIcon *icon = HIPPO_STATUS_ICON(gtk_icon);
    GtkWidget *menu_item;
    GtkWidget *label;

    /* We used to only show the Quit item in "leet_mode" */
    GdkModifierType state;
    gboolean leet_mode;
    
    leet_mode = FALSE;
    if (gtk_get_current_event_state(&state)) {
        if (state & GDK_CONTROL_MASK)
            leet_mode = TRUE;
    }
    
    destroy_menu(icon);
    
    icon->popup_menu = gtk_menu_new();

    menu_item = gtk_image_menu_item_new_from_stock(GTK_STOCK_HOME, NULL);
    label = gtk_bin_get_child(GTK_BIN(menu_item));
    gtk_label_set_text(GTK_LABEL(label), _("My Mugshot home page"));
    g_signal_connect_swapped(menu_item, "activate", G_CALLBACK(hippo_app_show_home),
        hippo_get_app());
    gtk_widget_show(menu_item);
    gtk_menu_shell_append(GTK_MENU_SHELL(icon->popup_menu), menu_item);
                
    menu_item = gtk_image_menu_item_new_from_stock(GTK_STOCK_ABOUT, NULL);
    g_signal_connect_swapped(menu_item, "activate", G_CALLBACK(hippo_app_show_about),
        hippo_get_app());
    gtk_widget_show(menu_item);
    gtk_menu_shell_append(GTK_MENU_SHELL(icon->popup_menu), menu_item);

    menu_item = gtk_separator_menu_item_new();
    gtk_widget_show(menu_item);
    gtk_menu_shell_append(GTK_MENU_SHELL(icon->popup_menu), menu_item);
    
    if (leet_mode) {
        menu_item = gtk_menu_item_new_with_label ("Toggle Connected");
        g_signal_connect_swapped(menu_item, "activate", G_CALLBACK(on_toggle_connected_activated),
                                 NULL);
        gtk_widget_show(menu_item);
        gtk_menu_shell_append(GTK_MENU_SHELL(icon->popup_menu), menu_item);
    }
    
    menu_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_QUIT, NULL);
    g_signal_connect_swapped(menu_item, "activate", G_CALLBACK(on_quit_activated),
                             NULL);
    gtk_widget_show(menu_item);
    gtk_menu_shell_append(GTK_MENU_SHELL(icon->popup_menu), menu_item);

    gtk_menu_popup (GTK_MENU(icon->popup_menu), NULL, NULL,
                    gtk_status_icon_position_menu, icon,
                    button, activate_time);
    gtk_menu_shell_select_first(GTK_MENU_SHELL(icon->popup_menu), FALSE);                    
}                             
Esempio n. 4
0
static gboolean
show_popup_menu (PlumaDocumentsPanel *panel,
		 GdkEventButton      *event)
{
	GtkWidget *menu;

	menu = gtk_ui_manager_get_widget (pluma_window_get_ui_manager (panel->priv->window),
					 "/NotebookPopup");
	g_return_val_if_fail (menu != NULL, FALSE);

	if (event != NULL)
	{
		gtk_menu_popup (GTK_MENU (menu),
				NULL,
				NULL,
				NULL,
				NULL,
				event->button,
				event->time);
	}
	else
	{
		gtk_menu_popup (GTK_MENU (menu),
				NULL,
				NULL,
				(GtkMenuPositionFunc) menu_position,
				panel,
				0,
				gtk_get_current_event_time ());

		gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
	}

	return TRUE;
}
Esempio n. 5
0
/**
 * ephy_node_view_popup:
 * @view: an #EphyNodeView widget
 * @menu: a #GtkMenu to be shown
 *
 * Triggers the popup of @menu in @view.
 **/
void
ephy_node_view_popup (EphyNodeView *view, GtkWidget *menu)
{
	GdkEvent *event;

	event = gtk_get_current_event ();
	if (event)
	{
		if (event->type == GDK_KEY_PRESS)
		{
			GdkEventKey *key = (GdkEventKey *) event;

			gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
					ephy_gui_menu_position_tree_selection,
					view, 0, key->time);
			gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
		}
		else if (event->type == GDK_BUTTON_PRESS)
		{
			GdkEventButton *button = (GdkEventButton *) event;

			gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL,
					NULL, button->button, button->time);
		}

		gdk_event_free (event);
	}
}
Esempio n. 6
0
static void
show_tree_popup_menu (GtkTreeView        *tree,
		      EomPluginManager *pm,
		      GdkEventButton     *event)
{
	if (pm->priv->popup_menu)
		gtk_widget_destroy (pm->priv->popup_menu);

	pm->priv->popup_menu = create_tree_popup_menu (pm);

	if (pm->priv->popup_menu == NULL)
		return;

	gtk_menu_attach_to_widget (GTK_MENU (pm->priv->popup_menu),
				   GTK_WIDGET (pm),
				   (GtkMenuDetachFunc) tree_popup_menu_detach);

	if (event != NULL) {
		gtk_menu_popup (GTK_MENU (pm->priv->popup_menu), NULL, NULL,
				NULL, NULL,
				event->button, event->time);
	} else {
		gtk_menu_popup (GTK_MENU (pm->priv->popup_menu), NULL, NULL,
				menu_position_under_tree_view, tree,
				0, gtk_get_current_event_time ());

		gtk_menu_shell_select_first (GTK_MENU_SHELL (pm->priv->popup_menu),
					     FALSE);
	}
}
static void
zoom_popup_menu (GtkWidget *widget, NautilusZoomControl *zoom_control)
{
	GtkMenu *menu;

	menu = create_zoom_menu (zoom_control);
	gtk_menu_popup (menu, NULL, NULL,
			menu_position_under_widget, widget,
			0, gtk_get_current_event_time ());
	gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
}
Esempio n. 8
0
/* Generates the history menu */
static gboolean show_history_menu(gpointer data) {
  /* Declare some variables */
  GtkWidget *menu = gtk_menu_new();
  menu = create_history_menu(menu);
  g_signal_connect((GObject*)menu, "selection-done", (GCallback)gtk_widget_destroy, NULL);
  /* Popup the menu... */
  gtk_widget_show_all(menu);
  gtk_menu_popup((GtkMenu*)menu, NULL, NULL, NULL, NULL, 1, gtk_get_current_event_time());
  gtk_menu_shell_select_first((GtkMenuShell*)menu, TRUE);
  /* Return FALSE so the g_timeout_add() function is called only once */
  return FALSE;
}
Esempio n. 9
0
/* Called when status icon is clicked */
static void show_clipit_menu(int menu_type) {
	/* If the menu is visible, we don't do anything, so that it gets hidden */
	if((statusicon_menu != NULL) && gtk_widget_get_visible((GtkWidget *)statusicon_menu))
		return;
	if(status_menu_lock)
		return;
	status_menu_lock = TRUE;
	/* Create the menu */
	statusicon_menu = create_tray_menu(statusicon_menu, menu_type);
	g_signal_connect((GObject*)statusicon_menu, "selection-done", (GCallback)gtk_widget_destroy, NULL);
	/* GENERATE THE MENU*/
	gtk_widget_set_visible(statusicon_menu, TRUE);
	gtk_menu_popup((GtkMenu*)statusicon_menu, NULL, NULL, gtk_status_icon_position_menu, status_icon, 1, gtk_get_current_event_time());
	gtk_menu_shell_select_first((GtkMenuShell*)statusicon_menu, TRUE);

	status_menu_lock = FALSE;
}
Esempio n. 10
0
static gboolean matenu_menu_bar_real_move_selected (GtkMenuShell* base, gint distance) {
	MatenuMenuBar * self;
	gboolean result = FALSE;
	self = (MatenuMenuBar*) base;
	if (((GtkMenuShell*) self)->active_menu_item == GTK_WIDGET (self->priv->_overflown_arrow)) {
		if (distance == 1) {
			gtk_menu_shell_select_first ((GtkMenuShell*) self, TRUE);
		} else {
			{
				gint i;
				i = matenu_shell_get_length ((MatenuShell*) self) - 1;
				{
					gboolean _tmp0_;
					_tmp0_ = TRUE;
					while (TRUE) {
						MatenuItem* item;
						MatenuItem* _tmp1_;
						GtkWidget* child;
						if (!_tmp0_) {
							i--;
						}
						_tmp0_ = FALSE;
						if (!(i >= 0)) {
							break;
						}
						item = matenu_shell_get_item ((MatenuShell*) self, i);
						child = _g_object_ref0 ((_tmp1_ = item, GTK_IS_WIDGET (_tmp1_) ? ((GtkWidget*) _tmp1_) : NULL));
						if (!matenu_menu_bar_child_need_overflown_arrow (self, child)) {
							gtk_menu_shell_select_item ((GtkMenuShell*) self, child);
						}
						_g_object_unref0 (child);
						_g_object_unref0 (item);
					}
				}
			}
		}
		result = TRUE;
		return result;
	} else {
		result = GTK_MENU_SHELL_CLASS (matenu_menu_bar_parent_class)->move_selected ((GtkMenuShell*) GTK_MENU_BAR (self), distance);
		return result;
	}
}
Esempio n. 11
0
static void
hn_others_button_menu_show (HNOthersButton * button)
{
  g_return_if_fail (button);
  
  if (!TASKNAVIGATOR_ITEM (button)->menu)
    hn_others_button_create_menu (button);

  gtk_menu_popup (TASKNAVIGATOR_ITEM (button)->menu,
		  NULL,
		  NULL,
		  (GtkMenuPositionFunc) hn_others_button_get_menu_position,
		  button,
		  1,
		  gtk_get_current_event_time ());
  
  gtk_menu_shell_select_first (GTK_MENU_SHELL (TASKNAVIGATOR_ITEM (button)->menu), 
		               TRUE);
}
Esempio n. 12
0
static gboolean
window_menu_key_press_event (GtkWidget   *widget,
                             GdkEventKey *event,
                             WindowMenu  *window_menu)
{
	GtkMenuShell *menu_shell;
	WnckSelector *selector;

	switch (event->keyval) {
	case GDK_KEY_KP_Enter:
	case GDK_KEY_ISO_Enter:
	case GDK_KEY_3270_Enter:
	case GDK_KEY_Return:
	case GDK_KEY_space:
	case GDK_KEY_KP_Space:
		selector = WNCK_SELECTOR(window_menu->selector);
		/* 
		 * We need to call _gtk_menu_shell_activate() here as is done in 
		 * window_key_press_handler in gtkmenubar.c which pops up menu
		 * when F10 is pressed.
		 *
		 * As that function is private its code is replicated here.
		 */
		menu_shell = GTK_MENU_SHELL (selector);
		/* FIXMEgpoo: We need either accessors or a workaround
		   to grab the focus */
#if 0
		if (!menu_shell->GSEAL(active)) {
			gtk_grab_add (GTK_WIDGET (menu_shell));
			menu_shell->GSEAL(have_grab) = TRUE;
			menu_shell->GSEAL(active) = TRUE;
		}
#endif
		gtk_menu_shell_select_first (menu_shell, FALSE);
		return TRUE;
	default:
		break;
	}
	
	return FALSE;
}
Esempio n. 13
0
static gboolean
show_popup_menu (PlumaDocumentsPanel *panel,
		 GdkEventButton      *event)
{
	GtkWidget *menu;

	menu = gtk_ui_manager_get_widget (pluma_window_get_ui_manager (panel->priv->window),
					 "/NotebookPopup");
	g_return_val_if_fail (menu != NULL, FALSE);

	if (event != NULL)
	{
		gtk_menu_popup_at_pointer (GTK_MENU (menu), NULL);
	}
	else
	{
		menu_popup_at_treeview_selection (menu, panel->priv->treeview);
		gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
	}

	return TRUE;
}
Esempio n. 14
0
static gboolean
show_tab_popup_menu (GeditDocumentsPanel *panel,
		     GeditTab            *tab,
		     GdkEventButton      *event)
{
	GtkWidget *menu;

	gedit_debug (DEBUG_PANEL);

	menu = gedit_notebook_popup_menu_new (panel->priv->window, tab);

	if (event != NULL)
	{
		gtk_menu_popup (GTK_MENU (menu),
				NULL,
				NULL,
				NULL,
				NULL,
				event->button,
				event->time);
	}
	else
	{
		gtk_menu_popup (GTK_MENU (menu),
				NULL,
				NULL,
				(GtkMenuPositionFunc)menu_position,
				panel,
				0,
				gtk_get_current_event_time ());

		gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
	}

	return TRUE;
}
Esempio n. 15
0
static gboolean main_window_real_key_press_event (GtkWidget* base, GdkEventKey* event) {
	MainWindow * self;
	gboolean result = FALSE;
	ListStack* _tmp0_;
	GreeterList* _tmp1_ = NULL;
	GreeterList* top;
	GdkEventKey _tmp2_;
	guint _tmp3_;
	self = (MainWindow*) base;
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = self->stack;
	_tmp1_ = list_stack_top (_tmp0_);
	top = _tmp1_;
	_tmp2_ = *event;
	_tmp3_ = _tmp2_.keyval;
	switch (_tmp3_) {
		case GDK_KEY_Escape:
		{
			GreeterList* _tmp4_;
			_tmp4_ = top;
			greeter_list_cancel_authentication (_tmp4_);
			break;
		}
		case GDK_KEY_Page_Up:
		case GDK_KEY_KP_Page_Up:
		{
			GreeterList* _tmp5_;
			_tmp5_ = top;
			greeter_list_scroll (_tmp5_, GREETER_LIST_SCROLL_TARGET_START);
			break;
		}
		case GDK_KEY_Page_Down:
		case GDK_KEY_KP_Page_Down:
		{
			GreeterList* _tmp6_;
			_tmp6_ = top;
			greeter_list_scroll (_tmp6_, GREETER_LIST_SCROLL_TARGET_END);
			break;
		}
		case GDK_KEY_Up:
		case GDK_KEY_KP_Up:
		{
			GreeterList* _tmp7_;
			_tmp7_ = top;
			greeter_list_scroll (_tmp7_, GREETER_LIST_SCROLL_TARGET_UP);
			break;
		}
		case GDK_KEY_Down:
		case GDK_KEY_KP_Down:
		{
			GreeterList* _tmp8_;
			_tmp8_ = top;
			greeter_list_scroll (_tmp8_, GREETER_LIST_SCROLL_TARGET_DOWN);
			break;
		}
		case GDK_KEY_F10:
		{
			MenuBar* _tmp9_;
			_tmp9_ = self->menubar;
			gtk_menu_shell_select_first ((GtkMenuShell*) _tmp9_, FALSE);
			break;
		}
		default:
		{
			GdkEventKey _tmp10_;
			gboolean _tmp11_ = FALSE;
			_tmp10_ = *event;
			_tmp11_ = GTK_WIDGET_CLASS (main_window_parent_class)->key_press_event ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self, GTK_TYPE_WINDOW, GtkWindow), &_tmp10_);
			result = _tmp11_;
			_g_object_unref0 (top);
			return result;
		}
	}
	result = TRUE;
	_g_object_unref0 (top);
	return result;
}
static void _take_screenshot (CDScreenshotOptions *pOptions)
{
    g_free (myData.cCurrentUri);
    myData.cCurrentUri = _make_screenshot (pOptions ? pOptions->bActiveWindow : FALSE,
                                           pOptions ? pOptions->cFolder : NULL,
                                           pOptions ? pOptions->cName   : NULL);

    if (myData.cCurrentUri)
    {
        // demands the attention; it helps localizing the menu and it shows the icon if the dock is hidden.
        if (myData.bFromShortkey)
        {
            CD_APPLET_DEMANDS_ATTENTION ("pulse", 1000);
        }

        // pop up the menu
        GtkWidget *pMenu = gldi_menu_new (myIcon);

        CD_APPLET_ADD_IN_MENU_WITH_STOCK_AND_DATA (D_("Copy the location"), GLDI_ICON_NAME_COPY, _cd_copy_location, pMenu, NULL);

        CD_APPLET_ADD_IN_MENU_WITH_STOCK_AND_DATA (D_("Open"), GLDI_ICON_NAME_FILE, _cd_open, pMenu, NULL);

        if (myData.pAppList == NULL)
        {
            /* It's always a .png file always made by Cairo
             *  ==> no need to recreate the list, to search for icons, etc.
             * But we have to use the right icon and then reverse the list
             */
            myData.pAppList = cairo_dock_fm_list_apps_for_file (myData.cCurrentUri);
            GList *a;
            gchar **pAppInfo; // name, icon, cmd
            gchar *cIconPath;
            for (a = myData.pAppList; a != NULL; a = a->next)
            {
                pAppInfo = a->data;
                if (pAppInfo[2] != NULL)
                {
                    cIconPath = cairo_dock_search_icon_s_path (pAppInfo[2],
                                cairo_dock_search_icon_size (GTK_ICON_SIZE_MENU));
                    g_free (pAppInfo[2]);
                    pAppInfo[2] = cIconPath;
                }
            }
            myData.pAppList = g_list_reverse (myData.pAppList); // it's normal, we received a reversed list
        }
        if (myData.pAppList)
        {
            GtkWidget *pSubMenu = CD_APPLET_ADD_SUB_MENU_WITH_IMAGE (D_("Open with"), pMenu, GLDI_ICON_NAME_OPEN);
            GList *pItem;
            gchar **pAppInfo;
            for (pItem = myData.pAppList; pItem != NULL; pItem = g_list_next (pItem))
            {
                pAppInfo = pItem->data;
                CD_APPLET_ADD_IN_MENU_WITH_STOCK_AND_DATA (pAppInfo[0], pAppInfo[2], _cd_launch_with, pSubMenu, pAppInfo[1]);
            }
        }
        CD_APPLET_ADD_IN_MENU_WITH_STOCK_AND_DATA (D_("Open parent folder"), GLDI_ICON_NAME_DIRECTORY, _cd_open_parent, pMenu, NULL);

        CD_APPLET_POPUP_MENU_ON_MY_ICON (pMenu);

        gtk_menu_shell_select_first (GTK_MENU_SHELL (pMenu), FALSE);  // must be done here, after the menu has been realized.

        // when the menu disappear, set the icon back to normal.
        g_signal_connect (G_OBJECT (pMenu),
                          "deactivate",
                          G_CALLBACK (_on_menu_deactivated),
                          NULL);
    }
    else  // show an error message
    {
        gldi_dialog_show_temporary_with_icon (D_("Unable to take a screenshot"), myIcon, myContainer, 7000, MY_APPLET_SHARE_DATA_DIR"/"MY_APPLET_ICON_FILE);
    }
}
static void
thunar_location_entry_button_clicked (GtkWidget           *button,
                                      ThunarLocationEntry *location_entry)
{
  ThunarShortcutsModel *model;
  ThunarIconFactory    *icon_factory;
  ThunarVfsVolume      *volume;
  GtkIconTheme         *icon_theme;
  const gchar          *icon_name;
  GtkTreeIter           iter;
  ThunarFile           *file;
  GtkWidget            *image;
  GtkWidget            *item;
  GtkWidget            *menu;
  GdkPixbuf            *icon;
  gint                  icon_size;
  gint                  width;

  _thunar_return_if_fail (THUNAR_IS_LOCATION_ENTRY (location_entry));
  _thunar_return_if_fail (GTK_IS_TOGGLE_BUTTON (button));

  /* allocate a new menu */
  menu = gtk_menu_new ();

  /* determine the icon theme and factory */
  icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (button));
  icon_factory = thunar_icon_factory_get_for_icon_theme (icon_theme);

  /* determine the icon size for menus */
  gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &icon_size, &icon_size);

  /* load the menu items from the shortcuts model */
  model = thunar_shortcuts_model_get_default ();
  if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter))
    {
      do
        {
          /* determine the file and volume for the item */
          gtk_tree_model_get (GTK_TREE_MODEL (model), &iter,
                              THUNAR_SHORTCUTS_MODEL_COLUMN_FILE, &file,
                              THUNAR_SHORTCUTS_MODEL_COLUMN_VOLUME, &volume,
                              -1);

          /* check if we have a separator here */
          if (G_UNLIKELY (file == NULL && volume == NULL))
            {
              /* generate a separator the menu */
              item = gtk_separator_menu_item_new ();
            }
          else if (G_UNLIKELY (volume != NULL))
            {
              /* generate an image menu item for the volume */
              item = gtk_image_menu_item_new_with_label (thunar_vfs_volume_get_name (volume));

              /* load the icon for the volume */
              icon_name = thunar_vfs_volume_lookup_icon_name (volume, icon_theme);
              icon = thunar_icon_factory_load_icon (icon_factory, icon_name, icon_size, NULL, FALSE);
              if (G_LIKELY (icon != NULL))
                {
                  /* generate an image for the menu item */
                  image = gtk_image_new_from_pixbuf (icon);
                  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
                  g_object_unref (G_OBJECT (icon));
                  gtk_widget_show (image);
                }
            }
          else
            {
              /* generate an image menu item for the file */
              item = gtk_image_menu_item_new_with_label (thunar_file_get_display_name (file));

              /* load the icon for the file and generate the image for the menu item */
              icon = thunar_icon_factory_load_file_icon (icon_factory, file, THUNAR_FILE_ICON_STATE_DEFAULT, icon_size);
              image = gtk_image_new_from_pixbuf (icon);
              gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
              g_object_unref (G_OBJECT (icon));
              gtk_widget_show (image);
            }

          /* connect the file and volume to the item */
          g_object_set_data_full (G_OBJECT (item), I_("thunar-vfs-volume"), volume, g_object_unref);
          g_object_set_data_full (G_OBJECT (item), I_("thunar-file"), file, g_object_unref);

          /* append the new item to the menu */
          g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (thunar_location_entry_item_activated), location_entry);
          gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
          gtk_widget_show (item);
        }
      while (gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &iter));
    }

  /* make sure the menu has atleast the same width as the location entry */
  width = GTK_WIDGET (location_entry)->allocation.width - 2 * gtk_container_get_border_width (GTK_CONTAINER (location_entry));
  if (G_LIKELY (menu->allocation.width < width))
    gtk_widget_set_size_request (menu, width, -1);

  /* select the first visible or selectable item in the menu */
  gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), TRUE);

  /* enable the button, making sure that we do not recurse on the "clicked" signal by temporarily blocking the handler */
  g_signal_handlers_block_by_func (G_OBJECT (button), G_CALLBACK (thunar_location_entry_button_clicked), location_entry);
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
  g_signal_handlers_unblock_by_func (G_OBJECT (button), G_CALLBACK (thunar_location_entry_button_clicked), location_entry);

  /* run the menu, taking ownership over the menu object */
  thunar_gtk_menu_run (GTK_MENU (menu), button, menu_position, location_entry, 1, gtk_get_current_event_time ());

  /* disable the button, making sure that we do not recurse on the "clicked" signal by temporarily blocking the handler */
  g_signal_handlers_block_by_func (G_OBJECT (button), G_CALLBACK (thunar_location_entry_button_clicked), location_entry);
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), FALSE);
  g_signal_handlers_unblock_by_func (G_OBJECT (button), G_CALLBACK (thunar_location_entry_button_clicked), location_entry);

  /* clean up */
  g_object_unref (G_OBJECT (icon_factory));
  g_object_unref (G_OBJECT (model));
}
Esempio n. 18
0
static VALUE
rg_select_first(VALUE self, VALUE search_sensitive)
{
    gtk_menu_shell_select_first(_SELF(self), RVAL2CBOOL(search_sensitive));
    return self;
}