summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mate-netbook.pot50
-rw-r--r--mate-window-picker-applet/applet.c39
-rw-r--r--mate-window-picker-applet/org.mate.panel.applet.mate-window-picker-applet.gschema.xml.in5
-rw-r--r--mate-window-picker-applet/task-title.c152
4 files changed, 204 insertions, 42 deletions
diff --git a/mate-netbook.pot b/mate-netbook.pot
index 936d505..aacc0af 100644
--- a/mate-netbook.pot
+++ b/mate-netbook.pot
@@ -27,52 +27,64 @@ msgstr ""
msgid "Show windows from all workspaces."
msgstr ""
+#: ../mate-window-picker-applet/org.mate.panel.applet.mate-window-picker-applet.gschema.xml.in.h:3
+#: ../mate-window-picker-applet/applet.c:329
+msgid "Show desktop title and logout button"
+msgstr ""
+
+#: ../mate-window-picker-applet/org.mate.panel.applet.mate-window-picker-applet.gschema.xml.in.h:4
+#: ../mate-window-picker-applet/applet.c:331
+msgid ""
+"Show a title for the desktop when no window is selected, and append a logout "
+"button."
+msgstr ""
+
#: ../mate-window-picker-applet/org.mate.panel.MateWindowPicker.mate-panel-applet.in.in.h:1
msgid "Window Picker Applet Factory"
msgstr ""
#: ../mate-window-picker-applet/org.mate.panel.MateWindowPicker.mate-panel-applet.in.in.h:2
-#: ../mate-window-picker-applet/applet.c:211
-#: ../mate-window-picker-applet/applet.c:212
+#: ../mate-window-picker-applet/applet.c:247
+#: ../mate-window-picker-applet/applet.c:248
msgid "Window Picker"
msgstr ""
-#: ../mate-window-picker-applet/applet.c:63
+#: ../mate-window-picker-applet/applet.c:65
msgid "_Preferences"
msgstr ""
-#: ../mate-window-picker-applet/applet.c:66
+#: ../mate-window-picker-applet/applet.c:68
msgid "_About"
msgstr ""
-#: ../mate-window-picker-applet/applet.c:247
+#: ../mate-window-picker-applet/applet.c:303
msgid "Preferences"
msgstr ""
-#: ../mate-window-picker-applet/task-title.c:252
-#: ../mate-window-picker-applet/task-title.c:259
-#: ../mate-window-picker-applet/task-title.c:302
-#: ../mate-window-picker-applet/task-title.c:309
-#: ../mate-window-picker-applet/task-title.c:436
-#: ../mate-window-picker-applet/task-title.c:484
-msgid "Home"
+#: ../mate-window-picker-applet/task-title.c:77
+#: ../mate-window-picker-applet/task-title.c:322
+msgid "Log off, switch user, lock screen or power down the computer"
msgstr ""
-#: ../mate-window-picker-applet/task-title.c:256
-#: ../mate-window-picker-applet/task-title.c:306
-#: ../mate-window-picker-applet/task-title.c:482
-msgid "Log off, switch user, lock screen or power down the computer"
+#: ../mate-window-picker-applet/task-title.c:93
+#, c-format
+msgid "There was an error executing '%s': %s"
+msgstr ""
+
+#: ../mate-window-picker-applet/task-title.c:316
+#: ../mate-window-picker-applet/task-title.c:584
+msgid "Desktop"
msgstr ""
-#: ../mate-window-picker-applet/task-title.c:278
+#: ../mate-window-picker-applet/task-title.c:347
msgid "Close window"
msgstr ""
-#: ../mate-window-picker-applet/task-title.c:457
+#: ../mate-window-picker-applet/task-title.c:608
msgid "Close"
msgstr ""
-#: ../mate-window-picker-applet/task-title.c:458
+#: ../mate-window-picker-applet/task-title.c:609
msgid "Close current window."
msgstr ""
diff --git a/mate-window-picker-applet/applet.c b/mate-window-picker-applet/applet.c
index 805c7b0..8f06693 100644
--- a/mate-window-picker-applet/applet.c
+++ b/mate-window-picker-applet/applet.c
@@ -40,6 +40,7 @@
#define APPLET_SCHEMA "org.mate.panel.applet.mate-window-picker-applet"
#define SHOW_WIN_KEY "show-all-windows"
+#define SHOW_HOME_TITLE_KEY "show-home-title"
typedef struct
{
@@ -89,6 +90,20 @@ on_show_all_windows_changed (GSettings *settings,
g_object_set (app->tasks, "show_all_windows", show_windows, NULL);
}
+static void
+on_show_home_title_changed (GSettings *settings,
+ gchar *key,
+ gpointer data)
+{
+ WinPickerApp *app;
+ gboolean show_home = FALSE;
+
+ app = (WinPickerApp*)data;
+
+ show_home = g_settings_get_boolean (settings, SHOW_HOME_TITLE_KEY);
+ g_object_set (app->title, "show_home_title", show_home, NULL);
+}
+
static inline void
force_no_focus_padding (GtkWidget *widget)
{
@@ -154,6 +169,8 @@ cw_applet_fill (MatePanelApplet *applet,
app->settings = mate_panel_applet_settings_new (applet, APPLET_SCHEMA);
g_signal_connect (app->settings, "changed::" SHOW_WIN_KEY,
G_CALLBACK (on_show_all_windows_changed), app);
+ g_signal_connect (app->settings, "changed::" SHOW_HOME_TITLE_KEY,
+ G_CALLBACK (on_show_home_title_changed), app);
app->applet = GTK_WIDGET (applet);
force_no_focus_padding (GTK_WIDGET (applet));
@@ -172,7 +189,8 @@ cw_applet_fill (MatePanelApplet *applet,
gtk_widget_show_all (GTK_WIDGET (applet));
on_show_all_windows_changed (app->settings, SHOW_WIN_KEY, app);
-
+ on_show_home_title_changed (app->settings, SHOW_HOME_TITLE_KEY, app);
+
action_group = gtk_action_group_new ("MateWindowPicker Applet Actions");
gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
gtk_action_group_add_actions (action_group,
@@ -238,6 +256,16 @@ on_show_win_key_checkbox_toggled (GtkToggleButton *check, gpointer null)
}
static void
+on_show_home_title_checkbox_toggled (GtkToggleButton *check, gpointer null)
+{
+ gboolean is_active;
+
+ is_active = gtk_toggle_button_get_active (check);
+
+ g_settings_set_boolean (mainapp->settings, SHOW_HOME_TITLE_KEY, is_active);
+}
+
+static void
display_prefs_dialog (GtkAction *action,
WinPickerApp *applet)
{
@@ -270,6 +298,15 @@ display_prefs_dialog (GtkAction *action,
g_signal_connect (check, "toggled",
G_CALLBACK (on_show_win_key_checkbox_toggled), NULL);
+ check = gtk_check_button_new_with_label (_("Show desktop title and logout button"));
+ gtk_widget_set_tooltip_text (GTK_WIDGET (check),
+ _("Show a title for the desktop when no window is selected, and append a logout button."));
+ gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, TRUE, 0);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check),
+ g_settings_get_boolean (mainapp->settings, SHOW_HOME_TITLE_KEY));
+ g_signal_connect (check, "toggled",
+ G_CALLBACK (on_show_home_title_checkbox_toggled), NULL);
+
check = gtk_label_new (" ");
gtk_box_pack_start (GTK_BOX (vbox), check, TRUE, TRUE, 0);
diff --git a/mate-window-picker-applet/org.mate.panel.applet.mate-window-picker-applet.gschema.xml.in b/mate-window-picker-applet/org.mate.panel.applet.mate-window-picker-applet.gschema.xml.in
index 100dd2a..f3af64c 100644
--- a/mate-window-picker-applet/org.mate.panel.applet.mate-window-picker-applet.gschema.xml.in
+++ b/mate-window-picker-applet/org.mate.panel.applet.mate-window-picker-applet.gschema.xml.in
@@ -5,5 +5,10 @@
<summary>Show all windows</summary>
<description>Show windows from all workspaces.</description>
</key>
+ <key name="show-home-title" type="b">
+ <default>false</default>
+ <summary>Show desktop title and logout button</summary>
+ <description>Show a title for the desktop when no window is selected, and append a logout button.</description>
+ </key>
</schema>
</schemalist>
diff --git a/mate-window-picker-applet/task-title.c b/mate-window-picker-applet/task-title.c
index 2262015..15c4247 100644
--- a/mate-window-picker-applet/task-title.c
+++ b/mate-window-picker-applet/task-title.c
@@ -31,8 +31,7 @@ G_DEFINE_TYPE (TaskTitle, task_title, GTK_TYPE_EVENT_BOX);
TASK_TYPE_TITLE, \
TaskTitlePrivate))
-#define LOGOUT "mate-session-save --kill --gui"
-#define SHOW_HOME_TITLE_KEY "show-home-title"
+#define LOGOUT "mate-session-save --logout-dialog"
struct _TaskTitlePrivate
{
@@ -49,15 +48,64 @@ struct _TaskTitlePrivate
gboolean mouse_in_close_button;
};
+enum
+{
+ PROP_0,
+ PROP_SHOW_HOME_TITLE
+};
+
static void disconnect_window (TaskTitle *title);
static gboolean
+start_logout_dialog (TaskTitle *title)
+{
+ GError *error = NULL;
+ GAppInfo *app_info;
+ GdkAppLaunchContext *launch_context;
+ GdkDisplay *display;
+ GdkScreen *gdkscreen;
+
+ g_return_val_if_fail (TASK_IS_TITLE (title), FALSE);
+
+ gdkscreen = gtk_widget_get_screen (GTK_WIDGET (title));
+ app_info = g_app_info_create_from_commandline (
+ LOGOUT, _("Log off, switch user, lock screen or power down the computer"),
+ G_APP_INFO_CREATE_NONE, &error);
+
+ if (!error) {
+ display = gdk_screen_get_display (gdkscreen);
+ launch_context = gdk_display_get_app_launch_context (display);
+ gdk_app_launch_context_set_screen (launch_context, gdkscreen);
+ g_app_info_launch (app_info, NULL, G_APP_LAUNCH_CONTEXT (launch_context), &error);
+ g_object_unref (launch_context);
+ return TRUE;
+ }
+
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
+ _("There was an error executing '%s': %s"),
+ LOGOUT, error->message);
+
+ g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
+
+ gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
+ gtk_window_set_screen (GTK_WINDOW (dialog), gdkscreen);
+
+ gtk_widget_show (dialog);
+ g_error_free (error);
+ return FALSE;
+}
+
+static gboolean
on_close_clicked (GtkButton *button,
GdkEventButton *event,
TaskTitle *title)
{
TaskTitlePrivate *priv;
WnckWindow *window;
+ gboolean ret;
g_return_val_if_fail (TASK_IS_TITLE (title), FALSE);
priv = title->priv;
@@ -78,10 +126,16 @@ on_close_clicked (GtkButton *button,
gdkscreen = gtk_widget_get_screen (GTK_WIDGET (title));
display = gdk_screen_get_display (gdkscreen);
wnck_window_close (window, gdk_x11_display_get_user_time (display));
+ ret = TRUE;
+ }
+ else if (priv->show_home_title)
+ {
+ // This is a logout click
+ ret = start_logout_dialog (title);
}
gtk_widget_queue_draw (GTK_WIDGET (title));
- return TRUE;
+ return ret;
}
static gboolean
@@ -254,7 +308,7 @@ on_active_window_changed (WnckScreen *screen,
{
if (priv->show_home_title)
{
- gtk_label_set_text (GTK_LABEL (priv->label), _("Home"));
+ gtk_label_set_text (GTK_LABEL (priv->label), _("Desktop"));
gtk_image_set_from_pixbuf (GTK_IMAGE (priv->button_image),
priv->quit_icon);
@@ -365,6 +419,60 @@ on_draw (GtkWidget *w, cairo_t *cr)
/* GObject stuff */
static void
+task_title_set_show_home_title (TaskTitle *title, gboolean show_home_title)
+{
+ TaskTitlePrivate *priv = title->priv;
+
+ priv->show_home_title = show_home_title;
+
+ g_debug ("Show home title: %s", show_home_title ? "true" : "false");
+
+ on_active_window_changed(priv->screen, priv->window, title);
+}
+
+static void
+task_title_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ TaskTitle *title = TASK_TITLE (object);
+ TaskTitlePrivate *priv;
+
+ g_return_if_fail (TASK_IS_TITLE (title));
+ priv = title->priv;
+
+ switch (prop_id)
+ {
+ case PROP_SHOW_HOME_TITLE:
+ g_value_set_boolean (value, priv->show_home_title);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+task_title_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ TaskTitle *title = TASK_TITLE (object);
+
+ g_return_if_fail (TASK_IS_TITLE (title));
+
+ switch (prop_id)
+ {
+ case PROP_SHOW_HOME_TITLE:
+ task_title_set_show_home_title (title, g_value_get_boolean (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
task_title_finalize (GObject *object)
{
TaskTitlePrivate *priv;
@@ -384,6 +492,17 @@ task_title_class_init (TaskTitleClass *klass)
GtkWidgetClass *wid_class = GTK_WIDGET_CLASS (klass);
obj_class->finalize = task_title_finalize;
+ obj_class->set_property = task_title_set_property;
+ obj_class->get_property = task_title_get_property;
+
+ g_object_class_install_property (obj_class,
+ PROP_SHOW_HOME_TITLE,
+ g_param_spec_boolean ("show_home_title",
+ "Show Home Title",
+ "Show Home Title",
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
wid_class->draw = on_draw;
g_type_class_add_private (obj_class, sizeof (TaskTitlePrivate));
@@ -404,8 +523,7 @@ task_title_init (TaskTitle *title)
priv->screen = wnck_screen_get_default ();
priv->window = NULL;
- /* FIXME we can add an option for this in future */
- /* now it's disabled with gsettings migration */
+ // Default values
priv->show_home_title = FALSE;
gtk_widget_add_events (GTK_WIDGET (title), GDK_ALL_EVENTS_MASK);
@@ -420,7 +538,7 @@ task_title_init (TaskTitle *title)
gtk_widget_set_no_show_all (priv->box, TRUE);
gtk_widget_show (priv->box);
- priv->label = gtk_label_new (_("Home"));
+ priv->label = gtk_label_new (_("Desktop"));
gtk_label_set_ellipsize (GTK_LABEL (priv->label), PANGO_ELLIPSIZE_END);
gtk_widget_set_halign (priv->label, GTK_ALIGN_START);
gtk_widget_set_valign (priv->label, GTK_ALIGN_CENTER);
@@ -454,27 +572,17 @@ task_title_init (TaskTitle *title)
g_signal_connect (priv->button, "draw",
G_CALLBACK (on_button_draw), title);
+ // Initialize button_image to allow easy setting by icon name after that.
gdkscreen = gtk_widget_get_screen (GTK_WIDGET (title));
theme = gtk_icon_theme_get_for_screen (gdkscreen);
- gtk_icon_size_lookup (GTK_ICON_SIZE_MENU,
- &width, &height);
-
- priv->quit_icon = gtk_icon_theme_load_icon (theme, "mate-logout", width, 0, NULL);
-
+ gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &width, &height);
+ priv->quit_icon = gtk_icon_theme_load_icon (theme, "system-log-out", width, 0, NULL);
priv->button_image = gtk_image_new_from_pixbuf (priv->quit_icon);
+
gtk_container_add (GTK_CONTAINER (priv->button), priv->button_image);
gtk_widget_show (priv->button_image);
- gtk_widget_set_tooltip_text (priv->button,
- _("Log off, switch user, lock screen or power "
- "down the computer"));
- gtk_widget_set_tooltip_text (GTK_WIDGET (title), _("Home"));
-
- if (priv->show_home_title)
- gtk_widget_set_state (GTK_WIDGET (title), GTK_STATE_ACTIVE);
- else
- gtk_widget_hide (priv->box);
-
+ gtk_widget_hide (priv->box);
gtk_widget_add_events (GTK_WIDGET (title), GDK_ALL_EVENTS_MASK);