Esempio n. 1
0
							GdkEventButton     *event, 
							MegaphoneApplet    *applet);
static void megaphone_applet_information_cb            (BonoboUIComponent  *uic,
							MegaphoneApplet    *applet, 
							const gchar        *verb_name);
static void megaphone_applet_preferences_cb            (BonoboUIComponent  *uic,
							MegaphoneApplet    *applet, 
							const gchar        *verb_name);
static void megaphone_applet_about_cb                  (BonoboUIComponent  *uic,
							MegaphoneApplet    *applet, 
							const gchar        *verb_name);

G_DEFINE_TYPE(MegaphoneApplet, megaphone_applet, PANEL_TYPE_APPLET)

static const BonoboUIVerb megaphone_applet_menu_verbs [] = {
	BONOBO_UI_UNSAFE_VERB ("information", megaphone_applet_information_cb),
	BONOBO_UI_UNSAFE_VERB ("preferences", megaphone_applet_preferences_cb),
	BONOBO_UI_UNSAFE_VERB ("about",       megaphone_applet_about_cb),
	BONOBO_UI_VERB_END
};

static const char* authors[] = {
	"Raphaël Slinckx <*****@*****.**>", 
	"Xavier Claessens <*****@*****.**>", 
	NULL
};

static void
megaphone_applet_class_init (MegaphoneAppletClass *class)
{
	GObjectClass *object_class;
                                          width, height,
                                          GDK_INTERP_BILINEAR);

        if (scaled != NULL) {
		gtk_image_set_from_pixbuf (GTK_IMAGE (sdd->image),
					   scaled);
		g_object_unref (scaled);
	} else
		gtk_image_set_from_pixbuf (GTK_IMAGE (sdd->image),
					   icon);

        g_object_unref (icon);
}

static const BonoboUIVerb show_desktop_menu_verbs [] = {
        BONOBO_UI_UNSAFE_VERB ("ShowDesktopHelp",        display_help_dialog),
        BONOBO_UI_UNSAFE_VERB ("ShowDesktopAbout",       display_about_dialog),
        BONOBO_UI_VERB_END
};

/* This updates things that should be consistent with the button's appearance,
 * and update_button_state updates the button appearance itself
 */
static void
update_button_display (ShowDesktopData *sdd)
{
        if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (sdd->button))) {
                wncklet_set_tooltip (sdd->button,
				     _("Click here to restore hidden windows."));
        } else {
                wncklet_set_tooltip (sdd->button,
Esempio n. 3
0
gboolean applet_main (MyPanelApplet *applet_widget, const gchar *iid, gpointer data) {
	streamer_applet *applet;
	char *zErrMsg;
	int res, i;
	char ui[24576];

	if (strcmp (iid, APPLET_ID) != 0) 
		return FALSE;

	// i18n
	setlocale (LC_ALL, "");
	bindtextdomain (PACKAGE_NAME, LOCALEDIR);
	bind_textdomain_codeset(PACKAGE_NAME, "utf-8");
	textdomain (PACKAGE_NAME);

	// Init 
	applet = g_malloc0(sizeof(streamer_applet));
	applet->applet = applet_widget;
	memset(&applet->xml_listen_url[0], '\0', 1024);
	memset(&applet->xml_bitrate[0], '\0', 1024);
	memset(&applet->xml_server_name[0], '\0', 1024);
	memset(&applet->xml_genre[0], '\0', 1024);
	memset(&applet->url[0], '\0', 1024);	
	memset(&applet->ui_fav[0], '\0', 10240);
	memset(&applet->ui_recent[0], '\0', 10240);
	applet->timestamp = time(NULL);
	applet->xml_curr_entries = 0;
	applet->icecast_total_entries = 0;
	applet->status = 0;

	for (i=0; i<10; i++) {
		memset(&applet->hash_fav[i].hash[0], '\0', 64);
		memset(&applet->hash_recent[i].hash[0], '\0', 64);
	}

	applet->settings.show_notifications = 0;
	applet->settings.duration_notifications = 5;

#ifdef HAVE_GNOME_2
	applet->bonobo_counter = 0;
#endif

	// Check home dir, copy skel database
	char applet_home_dir[1024], skel_file[1024], local_file[1024];
	struct stat stat_buf;
	struct passwd *pw = getpwuid(getuid());
	sprintf(&applet_home_dir[0], "%s/%s", pw->pw_dir, APPLET_HOME_DIR);
	int stat_res = stat(&applet_home_dir[0], &stat_buf);
	int errsv = errno;
	if ((stat_res == 0) && (!S_ISDIR(stat_buf.st_mode))){
			push_notification(_("Streamer Applet Error"), _("Cannot access configuration directory. Exiting."), NULL, DEFAULT_NOTIFICATION_DURATION);
			return FALSE;
	}
	else if (stat_res == -1) {
		if (errsv == ENOENT) {
			int mkdir_res = mkdir(&applet_home_dir[0], 0755);
			if (mkdir_res == 1) {
				push_notification(_("Streamer Applet Error"), _("Cannot create configuration directory. Exiting."), NULL, DEFAULT_NOTIFICATION_DURATION);
				return FALSE;
			}
		}
		else {
			push_notification(_("Streamer Applet Error"), _("Cannot verify configuration directory. Exiting."), NULL, DEFAULT_NOTIFICATION_DURATION);
			return FALSE;
		}
	}
	sprintf(&skel_file[0], "%s/%s", APPLET_SKEL_PATH, APPLET_SQLITE_DB_FILENAME);
	sprintf(&local_file[0], "%s/%s/%s", pw->pw_dir, APPLET_HOME_DIR, APPLET_SQLITE_DB_FILENAME);
	stat_res = stat(&local_file[0], &stat_buf);
	errsv = errno;
	if ((stat_res == 0) && (!S_ISREG(stat_buf.st_mode))){
		push_notification(_("Streamer Applet Error"), _("Database file is not a regular file. Exiting."), NULL, DEFAULT_NOTIFICATION_DURATION);
	}
	else if (stat_res == -1) {
		if (errsv == ENOENT) {
			if (!cp(&local_file[0], &skel_file[0])) {
				push_notification(_("Streamer Applet Error"), _("Cannot copy database file to configuration directory. Exiting."), NULL, DEFAULT_NOTIFICATION_DURATION);
				return FALSE;
			}
		}
		else {
			push_notification(_("Streamer Applet Error"), _("Cannot verify database file. Exiting."), NULL, DEFAULT_NOTIFICATION_DURATION);
			return FALSE;
		}
	}
	
	// Test DB connection, upgrade DB if necessary
	if (!sqlite_connect(applet)) {
		push_notification(_("Streamer Applet Error"), _("Unable to connect to DB. Exiting."), NULL, DEFAULT_NOTIFICATION_DURATION);
		return FALSE;
	}

	zErrMsg = 0;
	res = sqlite3_exec(applet->sqlite, "SELECT version FROM version", cb_sql_version, (void*) applet, &zErrMsg);
	if (res != SQLITE_OK) {
		push_notification(_("Streamer Applet Error"), zErrMsg, NULL, DEFAULT_NOTIFICATION_DURATION);
		sqlite3_free(zErrMsg);
		return FALSE;
	}

	if (applet->db_version == 1) {
		// Upgrade DB to version 2
		sqlite_insert(applet, "CREATE TABLE custom_stations (server_name VARCHAR(255), listen_url VARCHAR(255), bitrate VARCHAR(255), genre VARCHAR(255))");
		sqlite_insert(applet, "ALTER TABLE stations RENAME TO icecast_stations");
		sqlite_insert(applet, "UPDATE version SET version=2");
	}
	else if (applet->db_version == 2) {
		// Upgrade DB to version 3
		sqlite_insert(applet, "CREATE TABLE rbrowser_stations (server_name VARCHAR(255), listen_url VARCHAR(255), bitrate VARCHAR(255), genre VARCHAR(255))");
		sqlite_insert(applet, "UPDATE version SET version=3");
	}

	sqlite3_close(applet->sqlite);

	// Init GStreamer
	gstreamer_init(applet);

	// Get an image
	char image_file[1024];
	sprintf(&image_file[0], "%s/%s", APPLET_ICON_PATH, APPLET_ICON_PAUSE);
	applet->image = gtk_image_new_from_file (&image_file[0]);

	// Put the image into a container (it needs to receive actions)
	applet->event_box = gtk_event_box_new();
	gtk_container_add (GTK_CONTAINER (applet->event_box), applet->image);

	// Put the container into the applet
	gtk_container_add (GTK_CONTAINER (applet->applet), applet->event_box);

	// Define menu action group
#ifdef HAVE_MATE
	applet->action_group = gtk_action_group_new ("Streamer_Applet_Actions");
	gtk_action_group_set_translation_domain(applet->action_group, PACKAGE_NAME);
	gtk_action_group_add_actions (applet->action_group, applet_menu_actions_mate, G_N_ELEMENTS (applet_menu_actions_mate), applet);
#endif

	// Get last 10 entried from Recent & Fav, then fetch last URL
	if (!sqlite_connect(applet))
		return FALSE;

	zErrMsg = 0;
	memset(&applet->ui_recent[0], '\0', 1);

	res = sqlite3_exec(applet->sqlite, "SELECT server_name, listen_url FROM recent GROUP BY listen_url ORDER BY unix_timestamp DESC LIMIT 10", cb_sql_recent_10, (void*) applet, &zErrMsg);
	if (res != SQLITE_OK) {
		push_notification(_("Streamer Applet Error"), zErrMsg, NULL, DEFAULT_NOTIFICATION_DURATION);
		sqlite3_free(zErrMsg);
		return FALSE;
	}

	memset(&applet->ui_fav[0], '\0', 1);
	res = sqlite3_exec(applet->sqlite, "SELECT server_name, listen_url FROM favourites LIMIT 10", cb_sql_fav_10, (void*) applet, &zErrMsg);
	if (res != SQLITE_OK) {
		push_notification(_("Streamer Applet Error"), zErrMsg, NULL, DEFAULT_NOTIFICATION_DURATION);
		sqlite3_free(zErrMsg);
		return FALSE;
	}

	res = sqlite3_exec(applet->sqlite, "SELECT * FROM recent ORDER BY unix_timestamp DESC LIMIT 1", cb_sql_recent, (void*) applet, &zErrMsg);
	if (res != SQLITE_OK) {
		push_notification(_("Streamer Applet Error"), zErrMsg, NULL, DEFAULT_NOTIFICATION_DURATION);
		sqlite3_free(zErrMsg);
		return FALSE;
	}

	sqlite3_free(zErrMsg);
	sqlite3_close(applet->sqlite);

	// Build menu
	sprintf(&ui[0], "%s %s %s %s %s", ui1, &applet->ui_recent[0], ui2, &applet->ui_fav[0], ui3);
#ifdef HAVE_MATE
	mate_panel_applet_setup_menu(applet->applet, &ui[0], applet->action_group);
#elif HAVE_GNOME_2
	BonoboUIVerb bnb1 = BONOBO_UI_UNSAFE_VERB ("All", G_CALLBACK (menu_cb_all));
	applet->applet_menu_actions_gnome[applet->bonobo_counter] = bnb1;
	applet->bonobo_counter++;
	BonoboUIVerb bnb1a = BONOBO_UI_UNSAFE_VERB ("Settings", G_CALLBACK (menu_cb_settings));
	applet->applet_menu_actions_gnome[applet->bonobo_counter] = bnb1a;
	applet->bonobo_counter++;
	BonoboUIVerb bnb2 = BONOBO_UI_UNSAFE_VERB ("About", G_CALLBACK (menu_cb_about));
	applet->applet_menu_actions_gnome[applet->bonobo_counter] = bnb2;
	applet->bonobo_counter++;
	BonoboUIVerb bnb3 = BONOBO_UI_VERB_END;
	applet->applet_menu_actions_gnome[applet->bonobo_counter] = bnb3;
	applet->bonobo_counter++;
	panel_applet_setup_menu(applet->applet, &ui[0], applet->applet_menu_actions_gnome, applet);
#endif

	// Merge menu
	//GError **error;
	//char ui[10240];
	//sprintf(&ui[0], "<menu action='SubMenu1'>\n<menuitem action='All'/>\n<menuitem action='All'/></menu>");
	//guint merge_id = gtk_ui_manager_add_ui_from_string (applet->applet->priv->ui_manager, &ui[0], -1, error);

	// Settings: Prepare DConf - GNOME2 only
#ifdef HAVE_GNOME_2
	if (!panel_applet_gconf_get_bool(PANEL_APPLET(applet->applet), "have_settings", NULL)) {
		panel_applet_gconf_set_bool(PANEL_APPLET(applet->applet), "have_settings", TRUE, NULL);
		panel_applet_gconf_set_int(PANEL_APPLET(applet->applet), APPLET_KEY_OPTION_1, 0, NULL);
		panel_applet_gconf_set_int(PANEL_APPLET(applet->applet), APPLET_KEY_OPTION_2, 5, NULL);
	}
#endif

	// Load settings
#ifdef HAVE_MATE
	applet->gsettings = g_settings_new_with_path(APPLET_GSETTINGS_SCHEMA, APPLET_GSETTINGS_PATH);
	applet->settings.show_notifications = g_settings_get_int(applet->gsettings, APPLET_KEY_OPTION_1);
	applet->settings.duration_notifications = g_settings_get_int(applet->gsettings, APPLET_KEY_OPTION_2);
#elif HAVE_GNOME_2
	applet->settings.show_notifications = panel_applet_gconf_get_int(PANEL_APPLET(applet->applet), APPLET_KEY_OPTION_1, NULL);
	applet->settings.duration_notifications = panel_applet_gconf_get_int(PANEL_APPLET(applet->applet), APPLET_KEY_OPTION_2, NULL);
#endif

	// Signals
	g_signal_connect(G_OBJECT(applet->event_box), "button_press_event", G_CALLBACK (on_left_click), (gpointer)applet);
	g_signal_connect(G_OBJECT(applet->applet), "change_background", G_CALLBACK (applet_back_change), (gpointer)applet);
	g_signal_connect(G_OBJECT(applet->applet), "destroy", G_CALLBACK(applet_destroy), (gpointer)applet);

	// Tooltip
	gtk_widget_set_tooltip_text (GTK_WIDGET (applet->applet), _("No stream selected. Right-click to load one."));

	// Show applet
	gtk_widget_show_all (GTK_WIDGET (applet->applet));

	// Run
	applet->loop = g_main_loop_new (NULL, FALSE);
	g_main_loop_run (applet->loop);

	return TRUE;
}
	pager->listeners[0] = 0;
	pager->listeners[1] = 0;
	pager->listeners[2] = 0;

	if (pager->properties_dialog)
		gtk_widget_destroy (pager->properties_dialog);

	if (pager->about)
		gtk_widget_destroy (pager->about);

	g_free (pager);
}

static const BonoboUIVerb pager_menu_verbs [] = {
	BONOBO_UI_UNSAFE_VERB ("PagerPreferences", display_properties_dialog),
	BONOBO_UI_UNSAFE_VERB ("PagerHelp",        display_help_dialog),
	BONOBO_UI_UNSAFE_VERB ("PagerAbout",       display_about_dialog),
        BONOBO_UI_VERB_END
};

static void
num_rows_changed (GConfClient *client,
		  guint        cnxn_id,
		  GConfEntry  *entry,
		  PagerData   *pager)
{
	int n_rows = DEFAULT_ROWS;
	
	if (entry->value != NULL &&
	    entry->value->type == GCONF_VALUE_INT) {
Esempio n. 5
0
  
  gtk_window_set_icon_name (GTK_WINDOW (data->about_dialog),
                            NOTIFICATION_AREA_ICON);
  gtk_window_set_screen (GTK_WINDOW (data->about_dialog), screen);

  g_object_add_weak_pointer (G_OBJECT (data->about_dialog),
                             (gpointer) &data->about_dialog);

  g_signal_connect (data->about_dialog, "response",
                    G_CALLBACK (gtk_widget_destroy), NULL);

  gtk_window_present (GTK_WINDOW (data->about_dialog));
}

static const BonoboUIVerb menu_verbs [] = {
  BONOBO_UI_UNSAFE_VERB ("SystemTrayHelp",       help_cb),
  BONOBO_UI_UNSAFE_VERB ("SystemTrayAbout",      about_cb),
  BONOBO_UI_VERB_END
};

static void
applet_change_background (PanelApplet               *applet,
                          PanelAppletBackgroundType  type,
                          GdkColor                  *color,
                          GdkPixmap                 *pixmap,
                          AppletData                *data)
{
  na_tray_force_redraw (data->tray);
}

	tasklist->listeners[1] = 0;
	tasklist->listeners[2] = 0;
	tasklist->listeners[3] = 0;
	tasklist->listeners[4] = 0;

	if (tasklist->properties_dialog)
		gtk_widget_destroy (tasklist->properties_dialog);

	if (tasklist->about)
		gtk_widget_destroy (tasklist->about);

        g_free (tasklist);
}

static const BonoboUIVerb tasklist_menu_verbs [] = {
	BONOBO_UI_UNSAFE_VERB ("TasklistPreferences", display_properties_dialog),
	BONOBO_UI_UNSAFE_VERB ("TasklistHelp",        display_help_dialog),
	BONOBO_UI_UNSAFE_VERB ("TasklistAbout",       display_about_dialog),
        BONOBO_UI_VERB_END
};

static void
tasklist_properties_update_content_radio (TasklistData *tasklist)
{
	GtkWidget *button;
	
	if (tasklist->show_current_radio == NULL)
		return;

	if (tasklist->include_all_workspaces) {
		button = tasklist->show_all_radio;
Esempio n. 7
0
static GladeXML *xml = NULL;
static gchar* glade_file=NULL;

static void show_error_dialog (gchar*,...);
static void show_warning_dialog (gchar*,...);
static int wireless_applet_timeout_handler (WirelessApplet *applet);
static void wireless_applet_properties_dialog (BonoboUIComponent *uic,
		WirelessApplet *applet);
static void wireless_applet_help_cb (BonoboUIComponent *uic,
		WirelessApplet *applet);
static void wireless_applet_about_cb (BonoboUIComponent *uic,
		WirelessApplet *applet);
static void prefs_response_cb (GtkDialog *dialog, gint response, gpointer data);

static const BonoboUIVerb wireless_menu_verbs [] = {
	BONOBO_UI_UNSAFE_VERB ("WirelessProperties",
			wireless_applet_properties_dialog),
	BONOBO_UI_UNSAFE_VERB ("WirelessHelp",
			wireless_applet_help_cb),
	BONOBO_UI_UNSAFE_VERB ("WirelessAbout",
			wireless_applet_about_cb),
	BONOBO_UI_VERB_END
};

static GType
wireless_applet_get_type (void)
{
	static GType type = 0;

	if (!type) {
		static const GTypeInfo info = {
			sizeof (PanelAppletClass),
Esempio n. 8
0
#include "ddcc-applet.h"

/* libddccontrol ipc */
#include "ddcpci-ipc.h"

#define GETTEXT_PACKAGE PACKAGE
#define GNOMELOCALEDIR LOCALEDIR

/* ****************
 * Constants
 * ****************/

/* Popup menu on the applet */
static const BonoboUIVerb ddccapplet_applet_menu_verbs[] = 
{
        BONOBO_UI_UNSAFE_VERB ("DdccAppletProperties", menu_properties_cb),
        BONOBO_UI_UNSAFE_VERB ("DdccAppletRunGddcontrol", menu_rungdcc_cb),
        BONOBO_UI_UNSAFE_VERB ("DdccAppletAbout", menu_about_cb),
        BONOBO_UI_VERB_END
};


/* ****************
 * Helpers
 * ****************/

/* display [msg] as popup errormessage */
static void
error_msg (char *msg)
{
	GtkWidget* dialog = 
Esempio n. 9
0
static GtkAllocation window_size = { 0, 0, 0, 0 };

static void
emmb_close (BonoboUIComponent *uid,
            gpointer data,
            const gchar *path)
{
	EMMessageBrowser *emmb = data;
	GtkWidget *toplevel;

	toplevel = gtk_widget_get_toplevel (GTK_WIDGET (emmb));
	gtk_widget_destroy (toplevel);
}

static BonoboUIVerb emmb_verbs[] = {
	BONOBO_UI_UNSAFE_VERB ("MessageBrowserClose", emmb_close),
	BONOBO_UI_VERB_END
};

static void
emmb_set_message (EMFolderView *emfv,
                  const gchar *uid,
                  gint nomarkseen)
{
	EMMessageBrowser *emmb = EM_MESSAGE_BROWSER (emfv);
	EMFolderViewClass *folder_view_class;
	CamelMessageInfo *info;

	/* Chain up to parent's set_message() method. */
	folder_view_class = EM_FOLDER_VIEW_CLASS (parent_class);
	folder_view_class->set_message (emfv, uid, nomarkseen);
Esempio n. 10
0
done:
        button_data->update_icon_idle = 0;
        return FALSE;
}

static void
queue_update_icon(ButtonData *button_data)
{
        if (button_data->update_icon_idle == 0) {
                button_data->update_icon_idle =
                        g_idle_add((GSourceFunc) update_icon_idle, button_data);
        }
}

static const BonoboUIVerb bigboard_button_menu_verbs [] = {
        BONOBO_UI_UNSAFE_VERB ("BigBoardButtonHelp",        display_help_dialog),
        BONOBO_UI_UNSAFE_VERB ("BigBoardButtonAbout",       display_about_dialog),
        BONOBO_UI_VERB_END
};

/* This updates things that should be consistent with the button's appearance,
 * and update_button_state updates the button's active flag (whether it's toggled on).
 */
static void
update_button_display (ButtonData *button_data)
{
        queue_update_icon (button_data);
        
        if (button_data->showing_bigboard)
                wncklet_set_tooltip (button_data->button, _("Click here to hide the desktop sidebar."));
        else
Esempio n. 11
0
		g_object_unref (pixbuf);

	/* Set up the widget. */
	gtk_window_set_wmclass (GTK_WINDOW (about), "gnocam-applet", 
				"Camera Applet");
	gnome_window_icon_set_from_file (GTK_WINDOW (about),
					 IMAGEDIR "gnocam-camera1.png");
	g_signal_connect (about, "destroy", G_CALLBACK (gtk_widget_destroyed),
			  &about);

	/* Show the widget. */
	gtk_widget_show (about);
}

static const BonoboUIVerb gnocam_applet_menu_verbs[] = {
	BONOBO_UI_UNSAFE_VERB ("Preferences", gnocam_applet_prefs_cb),
	BONOBO_UI_UNSAFE_VERB ("About", gnocam_applet_about_cb),
	BONOBO_UI_VERB_END
};

static void
notify_func (GConfClient *client, guint cnxn_id, GConfEntry *entry,
	     gpointer user_data)
{
	GnocamApplet *a = GNOCAM_APPLET (user_data);
	GnocamAppletCam *c;
	const gchar *b = g_basename (entry->key);
	gchar *id;

	if (!strcmp (entry->key, "/desktop/gnome/cameras")) return;