コード例 #1
0
/* Connect Server
 */
static void
panel_action_connect_server (GtkWidget *widget)
{
	GdkScreen *screen;
	char      *command;
	GError    *error;

	screen = gtk_widget_get_screen (GTK_WIDGET (widget));
	error = NULL;

	if (panel_is_program_in_path ("caja-connect-server"))
		command = g_strdup ("caja-connect-server");
	else if (panel_is_program_in_path ("nautilus-connect-server"))
		command = g_strdup ("nautilus-connect-server");
	else
		command = g_strdup ("nemo-connect-server");

	mate_gdk_spawn_command_line_on_screen (screen, command, &error);
	g_free (command);

	if (error) {
		panel_error_dialog (NULL, screen,
				    "cannot_connect_server",
				    TRUE,
				    _("Could not connect to server"),
				    error->message);
		g_clear_error (&error);
	}
}
コード例 #2
0
static void
panel_menu_button_load (const char  *menu_path,
			gboolean     use_menu_path,
			const char  *custom_icon,
			gboolean     use_custom_icon,
			const char  *tooltip,
			PanelWidget *panel,
			gboolean     locked,
			int          position,
			gboolean     exactpos,
			gboolean     has_arrow,
			const char  *id)
{
	PanelMenuButton *button;
	AppletInfo      *info;

	g_return_if_fail (panel != NULL);

	button = g_object_new (PANEL_TYPE_MENU_BUTTON,
			       "menu-path", menu_path,
			       "custom-icon", custom_icon,
			       "tooltip", tooltip,
			       "use-menu-path", use_menu_path,
			       "use-custom-icon", use_custom_icon,
			       "has-arrow", has_arrow,
			       NULL);

	info = mate_panel_applet_register (GTK_WIDGET (button), NULL, NULL,
				      panel, locked, position, exactpos,
				      PANEL_OBJECT_MENU, id);
	if (!info) {
		gtk_widget_destroy (GTK_WIDGET (button));
		return;
	}

	button->priv->applet_id = g_strdup (info->id);

	mate_panel_applet_add_callback (info, "help", GTK_STOCK_HELP, _("_Help"), NULL);

        if (!panel_lockdown_get_locked_down () &&
            (panel_is_program_in_path ("mozo") ||
	    panel_is_program_in_path ("matemenu-simple-editor")))
		mate_panel_applet_add_callback (info, "edit", NULL,
					   _("_Edit Menus"), NULL);

	panel_widget_set_applet_expandable (panel, GTK_WIDGET (button), FALSE, TRUE);
	panel_widget_set_applet_size_constrained (panel, GTK_WIDGET (button), TRUE);

	panel_menu_button_connect_to_gsettings (button);

	panel_lockdown_notify_add (G_CALLBACK (panel_menu_button_recreate_menu),
				   button);
}
コード例 #3
0
ファイル: panel-util.c プロジェクト: Displacer/mate-panel
static char* panel_lock_screen_action_get_command(const char* action)
{
	char* command = NULL;
	gboolean use_gscreensaver = FALSE;

	if (panel_is_program_in_path("mate-screensaver-command") && panel_is_program_in_path("mate-screensaver-preferences"))
	{
		use_gscreensaver = TRUE;
	}
	else if (!panel_is_program_in_path("xscreensaver-command"))
	{
		return NULL;
	}

	if (strcmp (action, "prefs") == 0)
	{
		if (use_gscreensaver)
		{
			command = g_strdup ("mate-screensaver-preferences");
		}
		else if (panel_is_program_in_path ("xscreensaver-demo"))
		{
			command = g_strdup ("xscreensaver-demo");
		}
		else
		{
			command = NULL;
		}
	}
	else if (strcmp (action, "activate") == 0 || strcmp(action, "lock") == 0)
	{
		/* Neither mate-screensaver or xscreensaver allow root
		 * to lock the screen */
		if (geteuid () == 0)
		{
			command = NULL;
		}
		else
		{
			if (use_gscreensaver)
			{
				command = g_strdup_printf("mate-screensaver-command --%s", action);
			}
			else
			{
				command = g_strdup_printf("xscreensaver-command -%s", action);
			}
		}
	}

	return command;
}
コード例 #4
0
void
panel_menu_button_invoke_menu (PanelMenuButton *button,
			       const char   *callback_name)
{
	GdkScreen *screen;

	g_return_if_fail (PANEL_IS_MENU_BUTTON (button));
	g_return_if_fail (callback_name != NULL);

	screen = gtk_widget_get_screen (GTK_WIDGET (button));

	if (!strcmp (callback_name, "help")) {
		panel_show_help (screen, "mate-user-guide", "gospanel-37", NULL);

	} else if (!strcmp (callback_name, "edit")) {

		if (panel_is_program_in_path ("menulibre"))
			panel_launch_desktop_file_with_fallback ("menulibre.desktop",
								 "menulibre",
								 screen, NULL);
		else
			panel_launch_desktop_file_with_fallback ("mozo.desktop",
								 "mozo",
								 screen, NULL);
	}
}
コード例 #5
0
ファイル: panel-menu-bar.c プロジェクト: wiliwe/gnome-panel
void
panel_menu_bar_load (PanelWidget *panel,
		     const char  *id,
		     GSettings   *settings)
{
	PanelMenuBar *menubar;

	g_return_if_fail (panel != NULL);

	menubar = g_object_new (PANEL_TYPE_MENU_BAR, NULL);

	menubar->priv->info = panel_applet_register (
					GTK_WIDGET (menubar), panel,
					PANEL_OBJECT_MENU_BAR, id,
					settings,
					NULL, NULL);
	if (!menubar->priv->info) {
		gtk_widget_destroy (GTK_WIDGET (menubar));
		return;
	}

	if (panel_is_program_in_path ("alacarte") ||
	    panel_is_program_in_path ("gmenu-simple-editor")) {
		panel_applet_add_callback (menubar->priv->info,
					   "edit",
					   NULL,
					   _("_Edit Menus"),
					   panel_lockdown_get_not_panels_locked_down_s);
	}

	panel_applet_add_callback (menubar->priv->info,
				   "help",
				   GTK_STOCK_HELP,
				   _("_Help"),
				   NULL);

	panel_menu_bar_object_object_load_finish (PANEL_MENU_BAR_OBJECT (menubar),
						  panel);
}
コード例 #6
0
ファイル: panel-menu-bar.c プロジェクト: j-rueger/mate-panel
static void panel_menu_bar_load(PanelWidget* panel, gboolean locked, int position, gboolean exactpos, const char* id)
{
	PanelMenuBar* menubar;

	g_return_if_fail (panel != NULL);

	menubar = g_object_new(PANEL_TYPE_MENU_BAR, NULL);

	menubar->priv->info = mate_panel_applet_register(GTK_WIDGET(menubar), NULL, NULL, panel, locked, position, exactpos, PANEL_OBJECT_MENU_BAR, id);

	if (!menubar->priv->info)
	{
		gtk_widget_destroy(GTK_WIDGET(menubar));
		return;
	}

	mate_panel_applet_add_callback(menubar->priv->info, "help", GTK_STOCK_HELP, _("_Help"), NULL);

	/* Menu editors */
	if (!panel_lockdown_get_locked_down () && (panel_is_program_in_path("mozo") || panel_is_program_in_path("matemenu-simple-editor")))
	{
		mate_panel_applet_add_callback (menubar->priv->info, "edit", NULL, _("_Edit Menus"), NULL);
	}

	g_signal_connect_after(menubar, "focus-in-event", G_CALLBACK(gtk_widget_queue_draw), menubar);
	g_signal_connect_after(menubar, "focus-out-event", G_CALLBACK(gtk_widget_queue_draw), menubar);
#if GTK_CHECK_VERSION (3, 0, 0)
	g_signal_connect_after(menubar, "draw", G_CALLBACK(panel_menu_bar_on_draw), menubar);
#else
	g_signal_connect_after(menubar, "expose-event", G_CALLBACK(panel_menu_bar_on_expose), menubar);
#endif

	gtk_widget_set_can_focus(GTK_WIDGET(menubar), TRUE);

	panel_widget_set_applet_expandable(panel, GTK_WIDGET(menubar), FALSE, TRUE);
	panel_menu_bar_update_visibility(menubar->priv->settings, NULL, menubar);
}
コード例 #7
0
ファイル: panel-menu-items.c プロジェクト: Lyude/mate-panel
static GtkWidget *
panel_place_menu_item_create_menu (PanelPlaceMenuItem *place_item)
{
	GtkWidget *places_menu;
	GtkWidget *item;
	char      *gsettings_name;
	char      *name;
	char      *uri;
	GFile     *file;

	places_menu = panel_create_menu ();

	file = g_file_new_for_path (g_get_home_dir ());
	uri = g_file_get_uri (file);
	name = panel_util_get_label_for_uri (uri);
	g_object_unref (file);

	panel_menu_items_append_place_item (PANEL_ICON_HOME, NULL,
					    name,
					    _("Open your personal folder"),
					    places_menu,
					    G_CALLBACK (activate_home_uri),
					    uri);
	g_free (name);
	g_free (uri);

	if (!g_settings_get_boolean (place_item->priv->caja_prefs_settings,
				     CAJA_PREFS_DESKTOP_IS_HOME_DIR_KEY)) {
		file = g_file_new_for_path (g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP));
		uri = g_file_get_uri (file);
		g_object_unref (file);

		panel_menu_items_append_place_item (
				PANEL_ICON_DESKTOP, NULL,
				/* Translators: Desktop is used here as in
				 * "Desktop Folder" (this is not the Desktop
				 * environment). */
				C_("Desktop Folder", "Desktop"),
				_("Open the contents of your desktop in a folder"),
				places_menu,
				G_CALLBACK (activate_desktop_uri),
				/* FIXME: if the dir changes, we'd need to update the drag data since the uri is not the same */
				uri);
		g_free (uri);
	}

	panel_place_menu_item_append_gtk_bookmarks (places_menu);
	add_menu_separator (places_menu);

	gsettings_name = g_settings_get_string (place_item->priv->caja_desktop_settings,
					        CAJA_DESKTOP_COMPUTER_ICON_NAME_KEY);
	panel_menu_items_append_from_desktop (places_menu,
					      "caja-computer.desktop",
					      gsettings_name,
                                              TRUE);
	if (gsettings_name)
		g_free (gsettings_name);

	panel_place_menu_item_append_local_gio (place_item, places_menu);
	add_menu_separator (places_menu);

	panel_menu_items_append_from_desktop (places_menu,
					      "mate-network-scheme.desktop",
					      NULL,
                                              TRUE);
	panel_place_menu_item_append_remote_gio (place_item, places_menu);

	if (panel_is_program_in_path ("caja-connect-server")) {
		item = panel_menu_items_create_action_item (PANEL_ACTION_CONNECT_SERVER);
		if (item != NULL)
			gtk_menu_shell_append (GTK_MENU_SHELL (places_menu),
					       item);
	}

	add_menu_separator (places_menu);

	panel_menu_items_append_from_desktop (places_menu,
					      "mate-search-tool.desktop",
					      NULL,
                                              FALSE);

	panel_recent_append_documents_menu (places_menu,
					    place_item->priv->recent_manager);

	return places_menu;
}
コード例 #8
0
static GtkWidget *
panel_place_menu_item_create_menu (PanelPlaceMenuItem *place_item)
{
	GtkWidget *places_menu;
	GtkWidget *item;
	char      *gsettings_name = NULL;
	char      *name;
	char      *uri;
	GFile     *file;

	places_menu = panel_create_menu ();

	file = g_file_new_for_path (g_get_home_dir ());
	uri = g_file_get_uri (file);
	name = panel_util_get_label_for_uri (uri);
	g_object_unref (file);

	panel_menu_items_append_place_item (PANEL_ICON_HOME, NULL,
					    name,
					    _("Open your personal folder"),
					    places_menu,
					    G_CALLBACK (activate_home_uri),
					    uri);
	g_free (name);
	g_free (uri);

	if (!place_item->priv->caja_prefs_settings ||
		!g_settings_get_boolean (place_item->priv->caja_prefs_settings,
				     CAJA_PREFS_DESKTOP_IS_HOME_DIR_KEY)) {
		file = g_file_new_for_path (g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP));
		uri = g_file_get_uri (file);
		g_object_unref (file);

		panel_menu_items_append_place_item (
				PANEL_ICON_DESKTOP, NULL,
				/* Translators: Desktop is used here as in
				 * "Desktop Folder" (this is not the Desktop
				 * environment). */
				C_("Desktop Folder", "Desktop"),
				_("Open the contents of your desktop in a folder"),
				places_menu,
				G_CALLBACK (activate_desktop_uri),
				/* FIXME: if the dir changes, we'd need to update the drag data since the uri is not the same */
				uri);
		g_free (uri);
	}

	panel_place_menu_item_append_gtk_bookmarks (places_menu, g_settings_get_uint (place_item->priv->menubar_settings, PANEL_MENU_BAR_MAX_ITEMS_OR_SUBMENU));
	add_menu_separator (places_menu);

	if (place_item->priv->caja_desktop_settings != NULL)
		gsettings_name = g_settings_get_string (place_item->priv->caja_desktop_settings,
								CAJA_DESKTOP_COMPUTER_ICON_NAME_KEY);

	if (PANEL_GLIB_STR_EMPTY (gsettings_name))
		gsettings_name = g_strdup (_("Computer"));

	panel_menu_items_append_place_item (
			PANEL_ICON_COMPUTER, NULL,
			gsettings_name,
			_("Browse all local and remote disks and folders accessible from this computer"),
			places_menu,
			G_CALLBACK (activate_uri),
			"computer://");

	if (gsettings_name)
		g_free (gsettings_name);

	panel_place_menu_item_append_local_gio (place_item, places_menu);
	add_menu_separator (places_menu);

	panel_menu_items_append_place_item (
			PANEL_ICON_NETWORK, NULL,
			_("Network"),
			_("Browse bookmarked and local network locations"),
			places_menu,
			G_CALLBACK (activate_uri),
			"network://");
	panel_place_menu_item_append_remote_gio (place_item, places_menu);

	if (panel_is_program_in_path ("caja-connect-server") ||
	    panel_is_program_in_path ("nautilus-connect-server") ||
	    panel_is_program_in_path ("nemo-connect-server")) {
		item = panel_menu_items_create_action_item (PANEL_ACTION_CONNECT_SERVER);
		if (item != NULL)
			gtk_menu_shell_append (GTK_MENU_SHELL (places_menu),
					       item);
	}

	add_menu_separator (places_menu);

	if (panel_is_program_in_path ("mate-search-tool"))
		panel_menu_items_append_from_desktop (places_menu,
						      "mate-search-tool.desktop",
						      NULL,
						      FALSE);
	else
		panel_menu_items_append_from_desktop (places_menu,
						      "gnome-search-tool.desktop",
						      NULL,
						      FALSE);

	panel_recent_append_documents_menu (places_menu,
					    place_item->priv->recent_manager);
/* Fix any failures of compiz/other wm's to communicate with gtk for transparency */
	GtkWidget *toplevel = gtk_widget_get_toplevel (places_menu);
	GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(toplevel));
	GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
	gtk_widget_set_visual(GTK_WIDGET(toplevel), visual); 

	return places_menu;
}
コード例 #9
0
ファイル: panel-menu-items.c プロジェクト: wiliwe/gnome-panel
static GtkWidget *
panel_place_menu_item_create_menu (PanelPlaceMenuItem *place_item)
{
	GtkWidget *places_menu;
	GtkWidget *item;
	char      *gconf_name;
	char      *name;
	char      *uri;
	GFile     *file;

	places_menu = panel_create_menu ();

	file = g_file_new_for_path (g_get_home_dir ());
	uri = g_file_get_uri (file);
	name = panel_util_get_label_for_uri (uri);
	g_object_unref (file);
	
	item = panel_menu_item_uri_new (uri, PANEL_ICON_HOME, NULL,
					name,
					_("Open your personal folder"),
					G_CALLBACK (activate_home_uri));
	gtk_menu_shell_append (GTK_MENU_SHELL (places_menu), item);

	g_free (name);
	g_free (uri);

	if (!gconf_client_get_bool (panel_gconf_get_client (),
				    DESKTOP_IS_HOME_DIR_KEY,
				    NULL)) {
		file = g_file_new_for_path (g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP));
		uri = g_file_get_uri (file);
		g_object_unref (file);
		
		item = panel_menu_item_uri_new (
				/* FIXME: if the dir changes, we'd need to update the drag data since the uri is not the same */
				uri, PANEL_ICON_DESKTOP, NULL,
				/* Translators: Desktop is used here as in
				 * "Desktop Folder" (this is not the Desktop
				 * environment). */
				C_("Desktop Folder", "Desktop"),
				_("Open the contents of your desktop in a folder"),
				G_CALLBACK (activate_desktop_uri));
		gtk_menu_shell_append (GTK_MENU_SHELL (places_menu), item);

		g_free (uri);
	}

	panel_place_menu_item_append_gtk_bookmarks (places_menu);
	add_menu_separator (places_menu);

	gconf_name = gconf_client_get_string (panel_gconf_get_client (),
					      COMPUTER_NAME_KEY,
					      NULL);

	if (gconf_name == NULL) {
		gconf_name = g_strdup (_("Computer"));
	}

	item = panel_menu_item_uri_new ("computer://",
					PANEL_ICON_COMPUTER, NULL,
					gconf_name,
					_("Browse all local and remote disks and folders accessible from this computer"),
					G_CALLBACK (activate_uri));
	gtk_menu_shell_append (GTK_MENU_SHELL (places_menu), item);
	g_free (gconf_name);

	panel_place_menu_item_append_local_gio (place_item, places_menu);
	add_menu_separator (places_menu);

	item = panel_menu_item_uri_new ("network://",
					PANEL_ICON_NETWORK, NULL,
					_("Network"),
					_("Browse bookmarked and local network locations"),
					G_CALLBACK (activate_uri));
	gtk_menu_shell_append (GTK_MENU_SHELL (places_menu), item);

	panel_place_menu_item_append_remote_gio (place_item, places_menu);

	if (panel_is_program_in_path ("nautilus-connect-server")) {
		item = panel_menu_items_create_action_item (PANEL_ACTION_CONNECT_SERVER);
		if (item != NULL)
			gtk_menu_shell_append (GTK_MENU_SHELL (places_menu),
					       item);
	}

	add_menu_separator (places_menu);

	item = panel_menu_item_desktop_new ("gnome-search-tool.desktop",
					    NULL,
					    FALSE);
	if (item)
		gtk_menu_shell_append (GTK_MENU_SHELL (places_menu), item);

	panel_recent_append_documents_menu (places_menu,
					    place_item->priv->recent_manager);

	return places_menu;
}