[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 429/473: Add command to edit profile.

noreply at xfce.org noreply at xfce.org
Mon Feb 16 23:59:59 CET 2015


This is an automated email from the git hooks/post-receive script.

gottcode pushed a commit to branch master
in repository panel-plugins/xfce4-whiskermenu-plugin.

commit 454a2877c5d0dd5af667efa740eeec55693ad7a1
Author: Graeme Gott <graeme at gottcode.org>
Date:   Tue Dec 9 19:46:01 2014 -0500

    Add command to edit profile.
---
 panel-plugin/profile-picture.cpp |   28 ++++++++++++++++++++++++++--
 panel-plugin/profile-picture.h   |    6 +++++-
 panel-plugin/settings.cpp        |    6 ++++--
 panel-plugin/settings.h          |    3 ++-
 panel-plugin/window.cpp          |    2 +-
 5 files changed, 38 insertions(+), 7 deletions(-)

diff --git a/panel-plugin/profile-picture.cpp b/panel-plugin/profile-picture.cpp
index 8ca088c..b70fd41 100644
--- a/panel-plugin/profile-picture.cpp
+++ b/panel-plugin/profile-picture.cpp
@@ -17,7 +17,10 @@
 
 #include "profile-picture.h"
 
+#include "command.h"
+#include "settings.h"
 #include "slot.h"
+#include "window.h"
 
 #include <libxfce4panel/libxfce4panel.h>
 
@@ -25,10 +28,17 @@ using namespace WhiskerMenu;
 
 //-----------------------------------------------------------------------------
 
-ProfilePicture::ProfilePicture()
+ProfilePicture::ProfilePicture(Window* window) :
+	m_window(window)
 {
 	m_image = xfce_panel_image_new();
 
+	GtkWidget* eventbox = gtk_event_box_new();
+	gtk_event_box_set_visible_window(GTK_EVENT_BOX(eventbox), false);
+	gtk_widget_add_events(eventbox, GDK_BUTTON_PRESS_MASK);
+	g_signal_connect_slot<GtkWidget*, GdkEvent*>(eventbox, "button-press-event", &ProfilePicture::on_button_press_event, this);
+	gtk_container_add(GTK_CONTAINER(eventbox), m_image);
+
 	gchar* path = g_build_filename(g_get_home_dir(), ".face", NULL);
 	GFile* file = g_file_new_for_path(path);
 	g_free(path);
@@ -41,7 +51,7 @@ ProfilePicture::ProfilePicture()
 
 	m_alignment = gtk_alignment_new(0.5, 0.5, 0, 0);
 	gtk_alignment_set_padding(GTK_ALIGNMENT(m_alignment), 0, 0, 10, 10);
-	gtk_container_add(GTK_CONTAINER(m_alignment), m_image);
+	gtk_container_add(GTK_CONTAINER(m_alignment), eventbox);
 }
 
 //-----------------------------------------------------------------------------
@@ -78,3 +88,17 @@ void ProfilePicture::on_file_changed(GFileMonitor*, GFile* file, GFile*, GFileMo
 }
 
 //-----------------------------------------------------------------------------
+
+void ProfilePicture::on_button_press_event()
+{
+	Command* command = wm_settings->command[Settings::CommandProfile];
+	if (!command->get_shown())
+	{
+		return;
+	}
+
+	m_window->hide();
+	command->activate();
+}
+
+//-----------------------------------------------------------------------------
diff --git a/panel-plugin/profile-picture.h b/panel-plugin/profile-picture.h
index d96b8e7..e70a0c6 100644
--- a/panel-plugin/profile-picture.h
+++ b/panel-plugin/profile-picture.h
@@ -23,10 +23,12 @@
 namespace WhiskerMenu
 {
 
+class Window;
+
 class ProfilePicture
 {
 public:
-	ProfilePicture();
+	ProfilePicture(Window* window);
 	~ProfilePicture();
 
 	GtkWidget* get_widget() const
@@ -36,8 +38,10 @@ public:
 
 private:
 	void on_file_changed(GFileMonitor* monitor, GFile* file, GFile* other_file, GFileMonitorEvent event_type);
+	void on_button_press_event();
 
 private:
+	Window* m_window;
 	GtkWidget* m_alignment;
 	GtkWidget* m_image;
 	GFileMonitor* m_file_monitor;
diff --git a/panel-plugin/settings.cpp b/panel-plugin/settings.cpp
index f7d2526..b00ed98 100644
--- a/panel-plugin/settings.cpp
+++ b/panel-plugin/settings.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013, 2104 Graeme Gott <graeme at gottcode.org>
  *
  * This library is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -37,7 +37,8 @@ static const char* const settings_command[Settings::CountCommands][2] = {
 	{ "command-lockscreen", "show-command-lockscreen" },
 	{ "command-switchuser", "show-command-switchuser" },
 	{ "command-logout",     "show-command-logout"     },
-	{ "command-menueditor", "show-command-menueditor" }
+	{ "command-menueditor", "show-command-menueditor" },
+	{ "command-profile",    "show-command-profile"    }
 };
 
 //-----------------------------------------------------------------------------
@@ -118,6 +119,7 @@ Settings::Settings() :
 	command[CommandSwitchUser] = new Command("system-users", _("Switch _Users"), "gdmflexiserver", _("Failed to switch users."));
 	command[CommandLogOut] = new Command("system-log-out", _("Log _Out"), "xfce4-session-logout", _("Failed to log out."));
 	command[CommandMenuEditor] = new Command("xfce4-menueditor", _("_Edit Applications"), "menulibre", _("Failed to launch menu editor."));
+	command[CommandProfile] = new Command("avatar-default", _("Edit _Profile"), "mugshot", _("Failed to edit profile."));
 
 	search_actions.push_back(new SearchAction(_("Man Pages"), "#", "exo-open --launch TerminalEmulator man %s", false, true));
 	search_actions.push_back(new SearchAction(_("Wikipedia"), "!w", "exo-open --launch WebBrowser https://en.wikipedia.org/wiki/%u", false, true));
diff --git a/panel-plugin/settings.h b/panel-plugin/settings.h
index bd24f96..506d259 100644
--- a/panel-plugin/settings.h
+++ b/panel-plugin/settings.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013, 2014 Graeme Gott <graeme at gottcode.org>
  *
  * This library is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -89,6 +89,7 @@ public:
 		CommandSwitchUser,
 		CommandLogOut,
 		CommandMenuEditor,
+		CommandProfile,
 		CountCommands
 	};
 	Command* command[CountCommands];
diff --git a/panel-plugin/window.cpp b/panel-plugin/window.cpp
index b363691..e5fada4 100644
--- a/panel-plugin/window.cpp
+++ b/panel-plugin/window.cpp
@@ -94,7 +94,7 @@ WhiskerMenu::Window::Window() :
 	gtk_box_pack_start(m_window_box, m_window_contents, true, true, 0);
 
 	// Create the profile picture
-	m_profilepic = new ProfilePicture;
+	m_profilepic = new ProfilePicture(this);
 
 	// Create the username label
 	const gchar* name = g_get_real_name();

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list