grim/guifications3
Clone
Summary
Browse
Changes
Graph
cleaned up some white space
2012-04-30, Gary Kramlich
79d652b1a03b
cleaned up some white space
/*
* Guifications - The end-all, be-all notification framework
* Copyright (C) 2003-2009 Gary Kramlich <grim@reaperworld.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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include
"gf_gtk_feeds.h"
#include
"gf_gtk_icon.h"
#include
"gf_gtk_prefs.h"
#include
"guifications-gtk.h"
#include
<glib.h>
#include
<gtk/gtk.h>
/******************************************************************************
* Structs
*****************************************************************************/
typedef
struct
{
GtkWidget
*
menu
;
GtkSizeGroup
*
sg
;
GtkWidget
*
prefs
;
GtkWidget
*
feeds
;
GtkWidget
*
pause
;
GtkWidget
*
quit
;
}
GfGtkIconMenu
;
/******************************************************************************
* Globals
*****************************************************************************/
static
GtkStatusIcon
*
icon
=
NULL
;
static
GfGtkIconMenu
*
menu
=
NULL
;
/******************************************************************************
* Menu stuff
*****************************************************************************/
static
void
gf_gtk_icon_menu_prefs_cb
(
GtkMenuItem
*
item
,
gpointer
data
)
{
gf_gtk_prefs_show
();
}
static
void
gf_gtk_icon_menu_feeds_cb
(
GtkMenuItem
*
item
,
gpointer
data
)
{
gf_gtk_feeds_show
();
}
static
void
gf_gtk_icon_menu_pause_cb
(
GtkMenuItem
*
item
,
gpointer
data
)
{
gf_log_info
(
"guifications-gtk"
,
"pausing... if we had the code to pause :)
\n
"
);
}
static
void
gf_gtk_icon_menu_quit_cb
(
GtkMenuItem
*
item
,
gpointer
data
)
{
gf_gtk_quit
();
}
static
void
gf_gtk_icon_build_menu
()
{
GtkWidget
*
item
=
NULL
;
menu
->
menu
=
gtk_menu_new
();
/* prefs */
menu
->
prefs
=
gtk_image_menu_item_new_from_stock
(
GTK_STOCK_PREFERENCES
,
NULL
);
g_signal_connect
(
G_OBJECT
(
menu
->
prefs
),
"activate"
,
G_CALLBACK
(
gf_gtk_icon_menu_prefs_cb
),
NULL
);
/* feeds */
menu
->
feeds
=
gtk_menu_item_new_with_label
(
_
(
"Feeds"
));
g_signal_connect
(
G_OBJECT
(
menu
->
feeds
),
"activate"
,
G_CALLBACK
(
gf_gtk_icon_menu_feeds_cb
),
NULL
);
/* separator */
item
=
gtk_separator_menu_item_new
();
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
menu
->
menu
),
item
);
/* pause */
menu
->
pause
=
gtk_image_menu_item_new_from_stock
(
GTK_STOCK_MEDIA_PAUSE
,
NULL
);
g_signal_connect
(
G_OBJECT
(
menu
->
pause
),
"activate"
,
G_CALLBACK
(
gf_gtk_icon_menu_pause_cb
),
NULL
);
/* separator */
item
=
gtk_separator_menu_item_new
();
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
menu
->
menu
),
item
);
/* quit */
menu
->
quit
=
gtk_image_menu_item_new_from_stock
(
GTK_STOCK_QUIT
,
NULL
);
g_signal_connect
(
G_OBJECT
(
menu
->
quit
),
"activate"
,
G_CALLBACK
(
gf_gtk_icon_menu_quit_cb
),
NULL
);
/* show it already!! */
gtk_widget_show
(
menu
->
menu
);
}
/******************************************************************************
* Icon stuff
*****************************************************************************/
static
void
gf_gtk_icon_activate_cb
(
GtkStatusIcon
*
icon
,
gpointer
data
)
{
gf_gtk_feeds_show
();
}
static
void
gf_gtk_icon_popup_menu_cb
(
GtkStatusIcon
*
icon
,
guint
b
,
guint
t
,
gpointer
d
)
{
gtk_menu_popup
(
GTK_MENU
(
menu
->
menu
),
NULL
,
NULL
,
gtk_status_icon_position_menu
,
icon
,
b
,
t
);
}
/******************************************************************************
* API
*****************************************************************************/
void
gf_gtk_icon_init
(
void
)
{
if
(
!
GTK_IS_STATUS_ICON
(
icon
))
{
gchar
*
file
=
g_build_filename
(
DATADIR
,
"pixmaps"
,
"guifications"
,
"gtk"
,
"tray_icon.png"
,
NULL
);
icon
=
gtk_status_icon_new_from_file
(
file
);
g_free
(
file
);
g_signal_connect
(
G_OBJECT
(
icon
),
"activate"
,
G_CALLBACK
(
gf_gtk_icon_activate_cb
),
NULL
);
g_signal_connect
(
G_OBJECT
(
icon
),
"popup-menu"
,
G_CALLBACK
(
gf_gtk_icon_popup_menu_cb
),
NULL
);
gtk_status_icon_set_visible
(
icon
,
TRUE
);
}
if
(
!
menu
)
{
menu
=
g_new0
(
GfGtkIconMenu
,
1
);
}
if
(
!
GTK_IS_MENU
(
menu
->
menu
))
{
gf_gtk_icon_build_menu
();
}
}
void
gf_gtk_icon_uninit
(
void
)
{
if
(
GTK_IS_STATUS_ICON
(
icon
))
{
g_object_unref
(
icon
);
icon
=
NULL
;
}
if
(
menu
)
{
if
(
GTK_IS_MENU
(
menu
-
menu
))
gtk_widget_destroy
(
menu
->
menu
);
g_free
(
menu
);
menu
=
NULL
;
}
}