From 9678406b81a65e3260508d01764dc475aa631b6d Mon Sep 17 00:00:00 2001 From: Jean-Philippe Orsini Date: Wed, 9 Nov 2011 19:17:17 +0000 Subject: [PATCH] status icon --- src/Makefile.am | 3 ++- src/Makefile.in | 15 ++++++++------- src/main.c | 4 ++++ src/ui_status.c | 37 +++++++++++++++++++++++++++++++++++++ src/ui_status.h | 25 +++++++++++++++++++++++++ 5 files changed, 76 insertions(+), 8 deletions(-) create mode 100644 src/ui_status.c create mode 100644 src/ui_status.h diff --git a/src/Makefile.am b/src/Makefile.am index 189bcde..f6e2f84 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -34,7 +34,8 @@ psensor_SOURCES = \ ui_graph.h ui_graph.c \ ui_pref.h ui_pref.c \ ui_sensorlist.h ui_sensorlist.c \ - ui_sensorpref.h ui_sensorpref.c + ui_sensorpref.h ui_sensorpref.c \ + ui_status.h ui_status.c if GTOP AM_CPPFLAGS += $(GTOP_CFLAGS) diff --git a/src/Makefile.in b/src/Makefile.in index 6906604..6e6109b 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -70,9 +70,9 @@ PROGRAMS = $(bin_PROGRAMS) am__psensor_SOURCES_DIST = compat.h cfg.h cfg.c graph.h graph.c main.c \ ui.h ui.c ui_color.h ui_color.c ui_graph.h ui_graph.c \ ui_pref.h ui_pref.c ui_sensorlist.h ui_sensorlist.c \ - ui_sensorpref.h ui_sensorpref.c ui_notify.h ui_notify.c \ - ui_appindicator.h ui_appindicator.c ui_unity.h ui_unity.c \ - rsensor.h rsensor.c + ui_sensorpref.h ui_sensorpref.c ui_status.h ui_status.c \ + ui_notify.h ui_notify.c ui_appindicator.h ui_appindicator.c \ + ui_unity.h ui_unity.c rsensor.h rsensor.c @LIBNOTIFY_TRUE@am__objects_1 = ui_notify.$(OBJEXT) @APPINDICATOR_TRUE@am__objects_2 = ui_appindicator.$(OBJEXT) @UNITY_TRUE@am__objects_3 = ui_unity.$(OBJEXT) @@ -80,8 +80,8 @@ am__psensor_SOURCES_DIST = compat.h cfg.h cfg.c graph.h graph.c main.c \ am_psensor_OBJECTS = cfg.$(OBJEXT) graph.$(OBJEXT) main.$(OBJEXT) \ ui.$(OBJEXT) ui_color.$(OBJEXT) ui_graph.$(OBJEXT) \ ui_pref.$(OBJEXT) ui_sensorlist.$(OBJEXT) \ - ui_sensorpref.$(OBJEXT) $(am__objects_1) $(am__objects_2) \ - $(am__objects_3) $(am__objects_4) + ui_sensorpref.$(OBJEXT) ui_status.$(OBJEXT) $(am__objects_1) \ + $(am__objects_2) $(am__objects_3) $(am__objects_4) psensor_OBJECTS = $(am_psensor_OBJECTS) psensor_LDADD = $(LDADD) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) @@ -318,8 +318,8 @@ AM_CPPFLAGS = -Wall -pedantic -Werror \ psensor_SOURCES = compat.h cfg.h cfg.c graph.h graph.c main.c ui.h \ ui.c ui_color.h ui_color.c ui_graph.h ui_graph.c ui_pref.h \ ui_pref.c ui_sensorlist.h ui_sensorlist.c ui_sensorpref.h \ - ui_sensorpref.c $(am__append_4) $(am__append_7) \ - $(am__append_14) $(am__append_17) + ui_sensorpref.c ui_status.h ui_status.c $(am__append_4) \ + $(am__append_7) $(am__append_14) $(am__append_17) dist_man_MANS = psensor.1 EXTRA_DIST = description.txt all: all-recursive @@ -415,6 +415,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ui_pref.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ui_sensorlist.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ui_sensorpref.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ui_status.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ui_unity.Po@am__quote@ .c.o: diff --git a/src/main.c b/src/main.c index 1953e4b..a88e25e 100644 --- a/src/main.c +++ b/src/main.c @@ -59,6 +59,8 @@ #if defined(HAVE_APPINDICATOR) || defined(HAVE_APPINDICATOR_029) #include "ui_appindicator.h" +#else +#include "ui_status.h" #endif #ifdef HAVE_LIBNOTIFY @@ -445,6 +447,8 @@ int main(int argc, char **argv) #if defined(HAVE_APPINDICATOR) || defined(HAVE_APPINDICATOR_029) ui_appindicator_init(&ui); +#else + ui_status_create(); #endif gdk_notify_startup_complete(); diff --git a/src/ui_status.c b/src/ui_status.c new file mode 100644 index 0000000..55f732c --- /dev/null +++ b/src/ui_status.c @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2010-2011 jeanfi@gmail.com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#include + +#include "log.h" +#include "ui_status.h" + +void ui_status_create() +{ + GtkStatusIcon *tray_icon; + + log_printf(LOG_DEBUG, "ui_status_create()"); + + tray_icon = gtk_status_icon_new(); + gtk_status_icon_set_from_icon_name(tray_icon, + GTK_STOCK_MEDIA_STOP); + gtk_status_icon_set_tooltip(tray_icon, + "Example Tray Icon"); + gtk_status_icon_set_visible(tray_icon, TRUE); +} diff --git a/src/ui_status.h b/src/ui_status.h new file mode 100644 index 0000000..677d5ee --- /dev/null +++ b/src/ui_status.h @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2010-2011 jeanfi@gmail.com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#ifndef _PSENSOR_UI_STATUS_H_ +#define _PSENSOR_UI_STATUS_H_ + +void ui_status_create(); + +#endif -- 2.7.4