Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AppIndicator Support #69

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ AC_PROG_INSTALL

AC_CONFIG_SRCDIR([src])
AC_CONFIG_MACRO_DIR([m4])

PKG_CHECK_MODULES([Gnomato],[gtkmm-3.0 >= 3.0.0, sqlite3, libnotify >= 0.7.3,
python2 >= 2.7])
python2 >= 2.7, appindicator3-0.1 ])

IT_PROG_INTLTOOL([0.35.0])

Expand Down
43 changes: 7 additions & 36 deletions src/win_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ WinMain::WinMain(BaseObjectType* cobject,
{
currentTask = 0;

showed = false;
started = false;

configs.load();
Expand Down Expand Up @@ -151,9 +150,6 @@ WinMain::~WinMain()

void WinMain::set_systray()
{

systray = Gtk::StatusIcon::create_from_file(GNOMATO_DATADIR "/tomato.png");

//criacao do menu para o systray
actMenu = Gtk::ActionGroup::create();

Expand All @@ -176,14 +172,10 @@ void WinMain::set_systray()

mnuSystray->add_ui_from_string(ui_info);

systray->set_tooltip_text("Gnomato");

systray->signal_popup_menu().
connect(sigc::mem_fun(*this,&WinMain::on_systray_popup));

systray->signal_activate().
connect(sigc::mem_fun(*this,&WinMain::on_systray_activated));

systray_indicator = app_indicator_new("gnomato-appindicator", "tomato.png", APP_INDICATOR_CATEGORY_APPLICATION_STATUS);
app_indicator_set_icon_theme_path(systray_indicator, GNOMATO_DATADIR);
app_indicator_set_status (systray_indicator, APP_INDICATOR_STATUS_ACTIVE);
app_indicator_set_menu(systray_indicator, static_cast<Gtk::Menu*>(mnuSystray->get_widget("/Popup"))->gobj());
}

// methods implementations
Expand Down Expand Up @@ -326,7 +318,6 @@ void WinMain::notify(const char *icon, const char *message)

void WinMain::force_show()
{
showed = true;
show();
}

Expand Down Expand Up @@ -405,26 +396,6 @@ void WinMain::run_python_script(string hook)
set_notification(PythonExecutor::result_as_string(result));
}

// callbacks implementations
void WinMain::on_systray_activated()
{
if(showed){
showed = false;
hide();
}else{
showed = true;
show();
}
}

void WinMain::on_systray_popup(guint button, guint activate_time)
{
Gtk::Menu* pMenu = static_cast<Gtk::Menu*>(mnuSystray->get_widget("/Popup"));

if(pMenu)
pMenu->popup(button, activate_time);
}

void WinMain::on_button_start_clicked()
{

Expand Down Expand Up @@ -710,17 +681,17 @@ Glib::ustring WinMain::get_current_list()

void WinMain::set_green_icon()
{
systray->set_from_file(GNOMATO_DATADIR "/tomato-green.png");
app_indicator_set_icon (systray_indicator, "tomato-green.png");
}

void WinMain::set_gray_icon()
{
systray->set_from_file(GNOMATO_DATADIR "/tomato-gray.png");
app_indicator_set_icon (systray_indicator, "tomato-gray.png");
}

void WinMain::set_red_icon()
{
systray->set_from_file(GNOMATO_DATADIR "/tomato.png");
app_indicator_set_icon (systray_indicator, "tomato.png");
}

WinMain::TasksView::TasksView(BaseObjectType* cobject,
Expand Down
6 changes: 2 additions & 4 deletions src/win_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <libnotify/notify.h>
#include <iostream>
#include <sstream>
#include <libappindicator/app-indicator.h>

#include "boost/date_time/posix_time/posix_time.hpp"

Expand Down Expand Up @@ -91,7 +92,6 @@ class WinMain: public Gtk::Window
};

// attributes
bool showed;
bool started;
unsigned int time_elapsed;
unsigned int minutes,seconds;
Expand Down Expand Up @@ -141,7 +141,7 @@ class WinMain: public Gtk::Window

ComboBoxText *cmbLists;

Glib::RefPtr<StatusIcon> systray;
AppIndicator *systray_indicator;
Glib::RefPtr<Gtk::UIManager> mnuSystray;

Glib::RefPtr<ActionGroup> actMenu;
Expand Down Expand Up @@ -180,8 +180,6 @@ class WinMain: public Gtk::Window

// callback methods
virtual void on_filter_changed();
virtual void on_systray_activated();
virtual void on_systray_popup(guint button, guint activate_time);
virtual void on_button_start_clicked();
virtual void on_button_restart_clicked();
virtual void on_button_finish_clicked();
Expand Down