void *run_indicator(void *arg) { AppIndicator *indicator; char icon[256]; force = (int *)arg; strcpy(icon, pathname); strcat(icon, "/clock_ind.png"); indicator = app_indicator_new("uManage-client", icon, APP_INDICATOR_CATEGORY_APPLICATION_STATUS); app_indicator_set_status(indicator, APP_INDICATOR_STATUS_ACTIVE); app_indicator_set_attention_icon(indicator, "indicator-messages-new"); build_menu(indicator); gtk_main (); return arg; }
static void pocketvox_indicator_init (PocketvoxIndicator *indicator) { g_return_if_fail(NULL != indicator); indicator->priv = G_TYPE_INSTANCE_GET_PRIVATE (indicator, TYPE_POCKETVOX_INDICATOR, PocketvoxIndicatorPrivate); PocketvoxIndicatorPrivate *priv = indicator->priv; priv->applet = app_indicator_new("pocketvox_indicator", "audio-input-microphone-high-symbolic", APP_INDICATOR_CATEGORY_APPLICATION_STATUS); priv->menu = gtk_menu_new(); priv->modulesMenu = gtk_menu_new(); priv->appsMenu = gtk_menu_new(); priv->apps = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, pocketvox_indicator_free_item); priv->state = POCKETVOX_STATE_RUN; priv->table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, pocketvox_indicator_free_item); }
void create_tray_icon (void) { dpy = XOpenDisplay(NULL); gxneur_config_read_str("show_in_the_tray", &show_in_the_tray); gxneur_config_read_str("rendering_engine", &rendering_engine); gxneur_config_add_notify("show_in_the_tray", show_in_the_tray_callback, NULL); gxneur_config_add_notify("rendering_engine", rendering_engine_callback, NULL); if (arg_show_in_the_tray) g_free(show_in_the_tray), show_in_the_tray = g_strdup(arg_show_in_the_tray); if (arg_rendering_engine) g_free(rendering_engine), rendering_engine = g_strdup(arg_rendering_engine); if (!show_in_the_tray) show_in_the_tray = g_strdup(DEFAULT_SHOW_IN_THE_TRAY); if (!rendering_engine) rendering_engine = g_strdup(DEFAULT_RENDERING_ENGINE); tray = g_new0(struct _tray_icon, 1); #ifdef HAVE_APP_INDICATOR tray->app_indicator = NULL; #endif tray->status_icon = NULL; tray->tray_icon = NULL; // Init pixbuf array for (int i = 0; i < MAX_LAYOUTS; i++) { tray->images[i] = NULL; } // Load images names for (int i = 0; i < xconfig->handle->total_languages; i++) { char *layout_name = strdup(xconfig->handle->languages[i].dir); tray->images[i] = g_strdup_printf("%s-%s", PACKAGE, layout_name); free(layout_name); } tray->menu = create_menu(tray, xconfig->manual_mode); int tray_icon_created = 0; int tray_icon_failed = 0; if (strcasecmp(rendering_engine, "AppIndicator") == 0) { #ifdef HAVE_APP_INDICATOR // App indicator tray->app_indicator = app_indicator_new ("X Neural Switcher", PACKAGE, APP_INDICATOR_CATEGORY_APPLICATION_STATUS); if (tray->app_indicator) { app_indicator_set_status (tray->app_indicator, APP_INDICATOR_STATUS_ACTIVE); app_indicator_set_menu (tray->app_indicator, tray->menu); tray_icon_created = 1; tray_icon_failed = 0; } else { tray_icon_failed = 1; } #else tray_icon_failed = 1; #endif } gint kbd_gr = get_active_kbd_group(dpy); // Tray icon if (strcasecmp(rendering_engine, "Built-in") == 0 /*|| tray_icon_failed*/) { tray->tray_icon = _gtk_tray_icon_new(_("X Neural Switcher")); if (tray->tray_icon) { g_signal_connect(G_OBJECT(tray->tray_icon), "button_press_event", G_CALLBACK(tray_icon_press), NULL); tray->evbox = gtk_event_box_new(); gtk_event_box_set_visible_window(GTK_EVENT_BOX(tray->evbox), 0); if (strcasecmp(show_in_the_tray, "Text") == 0) { char *layout_name = strdup(xconfig->handle->languages[kbd_gr].dir); for (unsigned int i=0; i < strlen(layout_name); i++) layout_name[i] = toupper(layout_name[i]); tray->image = gtk_label_new ((const gchar *)layout_name); gtk_label_set_justify (GTK_LABEL(tray->image), GTK_JUSTIFY_CENTER); free(layout_name); } else { tray->image = gtk_image_new_from_icon_name(tray->images[kbd_gr], GTK_ICON_SIZE_LARGE_TOOLBAR); } gtk_container_add(GTK_CONTAINER(tray->evbox), tray->image); gtk_container_add(GTK_CONTAINER(tray->tray_icon), tray->evbox); gtk_widget_show_all(GTK_WIDGET(tray->tray_icon)); tray_icon_created = 1; tray_icon_failed = 0; } else { tray_icon_failed = 1; } } // Status Icon if (tray_icon_failed || !tray_icon_created || strcasecmp(rendering_engine, "StatusIcon") == 0 ) { tray->status_icon = gtk_status_icon_new(); g_signal_connect(G_OBJECT(tray->status_icon), "activate", G_CALLBACK(status_icon_on_click), NULL); g_signal_connect(G_OBJECT(tray->status_icon), "popup-menu", G_CALLBACK(status_icon_on_menu), NULL); gtk_status_icon_set_from_icon_name(tray->status_icon, PACKAGE); gtk_status_icon_set_tooltip_text(tray->status_icon, "X Neural Switcher"); gtk_status_icon_set_visible(tray->status_icon, TRUE); if (strcasecmp(show_in_the_tray, "Text") == 0) { char *layout_name = strdup(xconfig->handle->languages[kbd_gr].dir); for (unsigned int i=0; i < strlen(layout_name); i++) layout_name[i] = toupper(layout_name[i]); GdkPixbuf *pb = text_to_gtk_pixbuf (layout_name); free(layout_name); pb = gdk_pixbuf_add_alpha(pb, TRUE, 255, 255, 255); gtk_status_icon_set_from_pixbuf(tray->status_icon, pb); g_object_unref(pb); } else { gtk_status_icon_set_from_icon_name(tray->status_icon, tray->images[kbd_gr]); } } force_update = TRUE; g_timeout_add(1000, clock_check, 0); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); mainWindow = this; // Start device manager KbManager::init(CKB_VERSION_STR); connect(KbManager::kbManager(), SIGNAL(kbConnected(Kb*)), this, SLOT(addDevice(Kb*))); connect(KbManager::kbManager(), SIGNAL(kbDisconnected(Kb*)), this, SLOT(removeDevice(Kb*))); connect(KbManager::kbManager(), SIGNAL(versionUpdated()), this, SLOT(updateVersion())); connect(KbManager::scanTimer(), SIGNAL(timeout()), this, SLOT(timerTick())); // Set up tray icon restoreAction = new QAction(tr("Restore"), this); closeAction = new QAction(tr("Quit ckb"), this); #ifdef USE_LIBAPPINDICATOR QString desktop = std::getenv("XDG_CURRENT_DESKTOP"); unityDesktop = (desktop.toLower() == "unity"); if(unityDesktop){ trayIcon = 0; indicatorMenu = gtk_menu_new(); indicatorMenuRestoreItem = gtk_menu_item_new_with_label("Restore"); indicatorMenuQuitItem = gtk_menu_item_new_with_label("Quit ckb"); gtk_menu_shell_append(GTK_MENU_SHELL(indicatorMenu), indicatorMenuRestoreItem); gtk_menu_shell_append(GTK_MENU_SHELL(indicatorMenu), indicatorMenuQuitItem); g_signal_connect(indicatorMenuQuitItem, "activate", G_CALLBACK(quitIndicator), this); g_signal_connect(indicatorMenuRestoreItem, "activate", G_CALLBACK(restoreIndicator), this); gtk_widget_show(indicatorMenuRestoreItem); gtk_widget_show(indicatorMenuQuitItem); indicator = app_indicator_new("ckb", "indicator-messages", APP_INDICATOR_CATEGORY_APPLICATION_STATUS); app_indicator_set_status(indicator, APP_INDICATOR_STATUS_ACTIVE); app_indicator_set_menu(indicator, GTK_MENU(indicatorMenu)); app_indicator_set_icon(indicator, "ckb"); } else #endif // USE_LIBAPPINDICATOR { trayIconMenu = new QMenu(this); trayIconMenu->addAction(restoreAction); trayIconMenu->addAction(closeAction); trayIcon = new QSystemTrayIcon(QIcon(":/img/ckb-logo.png"), this); trayIcon->setContextMenu(trayIconMenu); connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconClicked(QSystemTrayIcon::ActivationReason))); } toggleTrayIcon(!CkbSettings::get("Program/SuppressTrayIcon").toBool()); #ifdef Q_OS_MACX // Make a custom "Close" menu action for OSX, as the default one brings up the "still running" popup unnecessarily QMenuBar* menuBar = new QMenuBar(this); setMenuBar(menuBar); this->menuBar()->addMenu("ckb")->addAction(closeAction); #else // On linux, add a handler for Ctrl+Q new QShortcut(QKeySequence("Ctrl+Q"), this, SLOT(quitApp())); #endif connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(quitApp())); connect(closeAction, SIGNAL(triggered()), this, SLOT(quitApp())); connect(restoreAction, SIGNAL(triggered()), this, SLOT(showWindow())); connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(stateChange(Qt::ApplicationState))); connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(cleanup())); ui->tabWidget->addTab(settingsWidget = new SettingsWidget(this), configLabel); settingsWidget->setVersion("ckb " CKB_VERSION_STR); }
int main (int argc, char **argv) { GError *error = NULL; gboolean no_daemon = FALSE; gboolean debug = FALSE; GOptionContext *context; GOptionEntry entries[] = { {"no-daemon", 0, 0, G_OPTION_ARG_NONE, &no_daemon, N_("Do not daemonize"), NULL}, {"debug", 0, 0, G_OPTION_ARG_NONE, &debug, N_("Log debugging message"), NULL}, {NULL} }; context = g_option_context_new ("- dasom daemon"); g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); g_option_context_parse (context, &argc, &argv, &error); g_option_context_free (context); if (error != NULL) { g_warning ("%s", error->message); g_error_free (error); return EXIT_FAILURE; } #ifdef ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, DASOM_LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif if (no_daemon == FALSE) { openlog (g_get_prgname (), LOG_PID | LOG_PERROR, LOG_DAEMON); syslog_initialized = TRUE; g_log_set_default_handler ((GLogFunc) dasom_log_default_handler, &debug); if (daemon (0, 0) != 0) { g_critical ("Couldn't daemonize."); return EXIT_FAILURE; } } gtk_init (&argc, &argv); AppIndicator *indicator; GtkWidget *menu_shell; GtkWidget *about_menu; GtkWidget *exit_menu; DasomAgent *agent; menu_shell = gtk_menu_new (); about_menu = gtk_menu_item_new_with_label (_("About")); exit_menu = gtk_menu_item_new_with_label (_("Exit")); gtk_widget_show_all (about_menu); gtk_widget_show_all (exit_menu); gtk_menu_shell_append (GTK_MENU_SHELL (menu_shell), about_menu); gtk_menu_shell_append (GTK_MENU_SHELL (menu_shell), exit_menu); gtk_widget_show_all (menu_shell); indicator = app_indicator_new ("dasom-indicator", "input-keyboard", APP_INDICATOR_CATEGORY_APPLICATION_STATUS); app_indicator_set_status (indicator, APP_INDICATOR_STATUS_ACTIVE); app_indicator_set_icon_full (indicator, "dasom-indicator", "Dasom"); app_indicator_set_menu (indicator, GTK_MENU (menu_shell)); agent = dasom_agent_new (); g_signal_connect (agent, "engine-changed", G_CALLBACK (on_engine_changed), indicator); g_signal_connect (agent, "disconnected", G_CALLBACK (on_disconnected), indicator); g_signal_connect (about_menu, "activate", G_CALLBACK (on_about_menu), indicator); g_signal_connect (exit_menu, "activate", G_CALLBACK (on_exit_menu), indicator); gtk_main (); g_object_unref (agent); g_object_unref (indicator); g_object_unref (menu_shell); if (syslog_initialized) closelog (); return EXIT_SUCCESS; }
int main (int argc, char *argv[]) { signal_user_data_t *ud; GValue *preset; GError *error = NULL; GOptionContext *context; #ifdef ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif if (!g_thread_supported()) g_thread_init(NULL); context = g_option_context_new ("- Transcode media formats"); g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); g_option_context_add_group (context, gtk_get_option_group (TRUE)); #if defined(_ENABLE_GST) g_option_context_add_group (context, gst_init_get_option_group ()); #endif g_option_context_parse (context, &argc, &argv, &error); g_option_context_free(context); if (argc > 1 && dvd_device == NULL && argv[1][0] != '-') { dvd_device = argv[1]; } gtk_init (&argc, &argv); gtk_rc_parse_string(hud_rcstyle); g_type_class_unref(g_type_class_ref(GTK_TYPE_BUTTON)); g_object_set(gtk_settings_get_default(), "gtk-button-images", TRUE, NULL); #if !defined(_WIN32) notify_init("HandBrake"); #endif ghb_register_transforms(); ghb_resource_init(); ghb_load_icons(); #if !defined(_WIN32) dbus_g_thread_init(); #endif ghb_udev_init(); ghb_write_pid_file(); ud = g_malloc0(sizeof(signal_user_data_t)); ud->debug = ghb_debug; g_log_set_handler (NULL, G_LOG_LEVEL_DEBUG, debug_log_handler, ud); g_log_set_handler ("Gtk", G_LOG_LEVEL_WARNING, warn_log_handler, ud); //g_log_set_handler ("Gtk", G_LOG_LEVEL_CRITICAL, warn_log_handler, ud); ud->settings = ghb_settings_new(); ud->builder = create_builder_or_die (BUILDER_NAME); // Enable events that alert us to media change events watch_volumes (ud); //GtkWidget *widget = GHB_WIDGET(ud->builder, "PictureDetelecineCustom"); //gtk_entry_set_inner_border(widget, 2); // Since GtkBuilder no longer assigns object ids to widget names // Assign a few that are necessary for style overrides to work GtkWidget *widget; #if defined(_NO_UPDATE_CHECK) widget = GHB_WIDGET(ud->builder, "check_updates_box"); gtk_widget_hide(widget); #endif widget = GHB_WIDGET(ud->builder, "preview_hud"); gtk_widget_set_name(widget, "preview_hud"); widget = GHB_WIDGET(ud->builder, "preview_window"); gtk_widget_set_name(widget, "preview_window"); // Set up the "hud" control overlay for the preview window GtkWidget *draw, *hud, *blender, *align; align = GHB_WIDGET(ud->builder, "preview_window_alignment"); draw = GHB_WIDGET(ud->builder, "preview_image_align"); hud = GHB_WIDGET(ud->builder, "preview_hud"); // Set up compositing for hud blender = ghb_compositor_new(); gtk_container_add(GTK_CONTAINER(align), blender); ghb_compositor_zlist_insert(GHB_COMPOSITOR(blender), draw, 1, 1); ghb_compositor_zlist_insert(GHB_COMPOSITOR(blender), hud, 2, .85); gtk_widget_show(blender); // Redirect stderr to the activity window ghb_preview_init(ud); IoRedirect(ud); ghb_log( "%s - %s - %s", HB_PROJECT_TITLE, HB_PROJECT_BUILD_TITLE, HB_PROJECT_URL_WEBSITE ); ghb_init_dep_map(); // Need to connect x264_options textview buffer to the changed signal // since it can't be done automatically GtkTextView *textview; GtkTextBuffer *buffer; textview = GTK_TEXT_VIEW(GHB_WIDGET (ud->builder, "x264Option")); buffer = gtk_text_view_get_buffer (textview); g_signal_connect(buffer, "changed", (GCallback)x264_entry_changed_cb, ud); ghb_combo_init(ud); g_debug("ud %p\n", ud); g_debug("ud->builder %p\n", ud->builder); bind_audio_tree_model(ud); bind_subtitle_tree_model(ud); bind_presets_tree_model(ud); bind_queue_tree_model(ud); bind_chapter_tree_model(ud); // Connect up the signals to their callbacks // I wrote my own connector so that I could pass user data // to the callbacks. Builder's standard autoconnect doesn't all this. gtk_builder_connect_signals_full (ud->builder, MyConnect, ud); // Load all internal settings ghb_settings_init(ud); // Load the presets files ghb_presets_load(ud); ghb_prefs_load(ud); ghb_prefs_to_ui(ud); gint logLevel; logLevel = ghb_settings_get_int(ud->settings, "LoggingLevel"); ghb_backend_init(logLevel); if (ghb_settings_get_boolean(ud->settings, "hbfd")) { ghb_hbfd(ud, TRUE); } gchar *source = ghb_settings_get_string(ud->settings, "default_source"); ghb_dvd_set_current(source, ud); g_free(source); // Parsing x264 options "" initializes x264 widgets to proper defaults ghb_x264_parse_options(ud, ""); // Populate the presets tree view ghb_presets_list_init(ud, NULL, 0); // Get the first preset name if (arg_preset != NULL) { preset = ghb_parse_preset_path(arg_preset); if (preset) { ghb_select_preset(ud->builder, preset); ghb_value_free(preset); } } else { ghb_select_default_preset(ud->builder); } // Grey out widgets that are dependent on a disabled feature ghb_check_all_depencencies (ud); if (dvd_device != NULL) { // Source overridden from command line option ghb_settings_set_string(ud->settings, "scan_source", dvd_device); g_idle_add((GSourceFunc)ghb_idle_scan, ud); } // Reload and check status of the last saved queue g_idle_add((GSourceFunc)ghb_reload_queue, ud); // Start timer for monitoring libhb status, 500ms g_timeout_add (500, ghb_timer_cb, (gpointer)ud); // Add dvd devices to File menu ghb_volname_cache_init(); g_thread_create((GThreadFunc)ghb_cache_volnames, ud, FALSE, NULL); #if defined(_USE_APP_IND) GtkUIManager * uim = GTK_UI_MANAGER(GHB_OBJECT(ud->builder, "uimanager1")); GtkMenu *ai_menu = GTK_MENU(gtk_ui_manager_get_widget(uim, "/ui/tray_menu")); ud->ai = app_indicator_new("HandBrake", "hb-icon", APP_INDICATOR_CATEGORY_APPLICATION_STATUS); app_indicator_set_menu( ud->ai, ai_menu ); app_indicator_set_label( ud->ai, "", "99.99%"); if (ghb_settings_get_boolean(ud->settings, "show_status")) { app_indicator_set_status( ud->ai, APP_INDICATOR_STATUS_ACTIVE ); } else { app_indicator_set_status( ud->ai, APP_INDICATOR_STATUS_PASSIVE ); } GtkStatusIcon *si; si = GTK_STATUS_ICON(GHB_OBJECT(ud->builder, "hb_status")); gtk_status_icon_set_visible(si, FALSE ); #else GtkStatusIcon *si; si = GTK_STATUS_ICON(GHB_OBJECT(ud->builder, "hb_status")); gtk_status_icon_set_visible(si, ghb_settings_get_boolean(ud->settings, "show_status")); #if GTK_CHECK_VERSION(2, 16, 0) gtk_status_icon_set_has_tooltip(si, TRUE); g_signal_connect(si, "query-tooltip", status_icon_query_tooltip_cb, ud); #else gtk_status_icon_set_tooltip(si, "HandBrake"); #endif #endif // Ugly hack to keep subtitle table from bouncing around as I change // which set of controls are visible GtkRequisition req; gint width, height; widget = GHB_WIDGET(ud->builder, "SrtCodeset"); gtk_widget_size_request( widget, &req ); height = req.height; widget = GHB_WIDGET(ud->builder, "srt_code_label"); gtk_widget_size_request( widget, &req ); height += req.height; widget = GHB_WIDGET(ud->builder, "subtitle_table"); gtk_widget_set_size_request(widget, -1, height); widget = GHB_WIDGET (ud->builder, "hb_window"); GdkGeometry geo = { -1, -1, 1024, 768, -1, -1, 10, 10, 0, 0, GDK_GRAVITY_NORTH_WEST }; GdkWindowHints geo_mask; geo_mask = GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE | GDK_HINT_BASE_SIZE; gtk_window_set_geometry_hints( GTK_WINDOW(widget), widget, &geo, geo_mask); width = ghb_settings_get_int(ud->settings, "window_width"); height = ghb_settings_get_int(ud->settings, "window_height"); gtk_window_resize(GTK_WINDOW(widget), width, height); gtk_widget_show(widget); /* * Filter objects in GtkBuilder xml * Unfortunately, GtkFilter is poorly supported by GtkBuilder, * so a lot of the setup must happen in code. SourceFilterAll SourceFilterVideo SourceFilterTS SourceFilterMPG SourceFilterEVO SourceFilterVOB SourceFilterMKV SourceFilterMP4 SourceFilterAVI SourceFilterMOV SourceFilterOGG SourceFilterFLV SourceFilterWMV */ // Add filters to source chooser GtkFileFilter *filter; GtkFileChooser *chooser; chooser = GTK_FILE_CHOOSER(GHB_WIDGET(ud->builder, "source_dialog")); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterAll")); gtk_file_filter_set_name(filter, "All"); gtk_file_filter_add_pattern(filter, "*"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterVideo")); gtk_file_filter_set_name(filter, "Video"); gtk_file_filter_add_mime_type(filter, "video/*"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterTS")); gtk_file_filter_set_name(filter, "TS"); gtk_file_filter_add_pattern(filter, "*.ts"); gtk_file_filter_add_pattern(filter, "*.TS"); gtk_file_filter_add_pattern(filter, "*.m2ts"); gtk_file_filter_add_pattern(filter, "*.M2TS"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterMPG")); gtk_file_filter_set_name(filter, "MPG"); gtk_file_filter_add_pattern(filter, "*.mpg"); gtk_file_filter_add_pattern(filter, "*.MPG"); gtk_file_filter_add_pattern(filter, "*.mepg"); gtk_file_filter_add_pattern(filter, "*.MEPG"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterEVO")); gtk_file_filter_set_name(filter, "EVO"); gtk_file_filter_add_pattern(filter, "*.evo"); gtk_file_filter_add_pattern(filter, "*.EVO"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterVOB")); gtk_file_filter_set_name(filter, "VOB"); gtk_file_filter_add_pattern(filter, "*.vob"); gtk_file_filter_add_pattern(filter, "*.VOB"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterMKV")); gtk_file_filter_set_name(filter, "MKV"); gtk_file_filter_add_pattern(filter, "*.mkv"); gtk_file_filter_add_pattern(filter, "*.MKV"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterMP4")); gtk_file_filter_set_name(filter, "MP4"); gtk_file_filter_add_pattern(filter, "*.mp4"); gtk_file_filter_add_pattern(filter, "*.MP4"); gtk_file_filter_add_pattern(filter, "*.m4v"); gtk_file_filter_add_pattern(filter, "*.M4V"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterMOV")); gtk_file_filter_set_name(filter, "MOV"); gtk_file_filter_add_pattern(filter, "*.mov"); gtk_file_filter_add_pattern(filter, "*.MOV"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterAVI")); gtk_file_filter_set_name(filter, "AVI"); gtk_file_filter_add_pattern(filter, "*.avi"); gtk_file_filter_add_pattern(filter, "*.AVI"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterOGG")); gtk_file_filter_set_name(filter, "OGG"); gtk_file_filter_add_pattern(filter, "*.ogg"); gtk_file_filter_add_pattern(filter, "*.OGG"); gtk_file_filter_add_pattern(filter, "*.ogv"); gtk_file_filter_add_pattern(filter, "*.OGV"); gtk_file_filter_add_pattern(filter, "*.ogm"); gtk_file_filter_add_pattern(filter, "*.OGM"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterFLV")); gtk_file_filter_set_name(filter, "FLV"); gtk_file_filter_add_pattern(filter, "*.flv"); gtk_file_filter_add_pattern(filter, "*.FLV"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterWMV")); gtk_file_filter_set_name(filter, "WMV"); gtk_file_filter_add_pattern(filter, "*.wmv"); gtk_file_filter_add_pattern(filter, "*.WMV"); gtk_file_chooser_add_filter(chooser, filter); // Gtk has a really stupid bug. If the file chooser is showing // hidden files AND there is no filter set, it will not select // the filename when gtk_file_chooser_set_filename is called. // So add a completely unnessary filter to prevent this behavior. filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterAll")); gtk_file_chooser_set_filter(chooser, filter); PangoFontDescription *font_desc; font_desc = pango_font_description_from_string ("monospace 10"); textview = GTK_TEXT_VIEW(GHB_WIDGET (ud->builder, "activity_view")); gtk_widget_modify_font(GTK_WIDGET(textview), font_desc); pango_font_description_free (font_desc); // Everything should be go-to-go. Lets rock! gtk_main (); gtk_status_icon_set_visible(si, FALSE); ghb_backend_close(); if (ud->queue) ghb_value_free(ud->queue); ghb_value_free(ud->settings); g_io_channel_unref(ud->activity_log); ghb_settings_close(); #if !defined(_WIN32) notify_uninit(); #endif g_free(ud); return 0; }
int main (int argc, char **argv) { /**********************************************************************************/ /* DAEMON SETUP */ /* Our process ID and Session ID */ pid_t pid, sid; /* Fork off the parent process */ pid = fork(); if (pid < 0) exit(EXIT_FAILURE); /* If we got a good PID, then we can exit the parent process. */ if (pid > 0) exit(EXIT_SUCCESS); /* Change the file mode mask */ umask(0); /* Open any logs here */ /* Create a new SID for the child process */ sid = setsid(); if (sid < 0) exit(EXIT_FAILURE); /* Change the current working directory */ if ((chdir("/")) < 0) exit(EXIT_FAILURE); /* Close out the standard file descriptors */ close(STDIN_FILENO); close(STDOUT_FILENO); close(STDERR_FILENO); /**********************************************************************************/ /* PROGRAM */ /* define variables gtk*/ GtkWidget *window; GtkWidget *indicator_menu; GtkActionGroup *action_group; GtkUIManager *uim; GError *error = NULL; AppIndicator *indicator; /* define custum variables */ int status = atoi(argv[1]); /* gtk init with no args */ gtk_init (0, NULL); /* main window */ window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), "Gnus Indicator"); g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL); /* Menus */ action_group = gtk_action_group_new ("AppActions"); gtk_action_group_add_actions (action_group, entries, n_entries, window); uim = gtk_ui_manager_new (); gtk_ui_manager_insert_action_group (uim, action_group, 0); if (!gtk_ui_manager_add_ui_from_string (uim, ui_info, -1, &error)) { g_message ("Failed to build menus: %s\n", error->message); g_error_free (error); error = NULL; } /* Indicator */ indicator_menu = gtk_ui_manager_get_widget (uim, "/ui/IndicatorPopup"); indicator = app_indicator_new ("example-simple-client", "/usr/share/pixmaps/gnome-gnus.png", APP_INDICATOR_CATEGORY_APPLICATION_STATUS); app_indicator_set_attention_icon(indicator, "/usr/share/pixmaps/gnome-gnus-new.png"); app_indicator_set_menu (indicator, GTK_MENU (indicator_menu)); /* set status */ if(status == 0) app_indicator_set_status (indicator, APP_INDICATOR_STATUS_ACTIVE); else if(status == 1) app_indicator_set_status (indicator, APP_INDICATOR_STATUS_ATTENTION); else app_indicator_set_status (indicator, APP_INDICATOR_STATUS_PASSIVE); gtk_main(); return 0; }
int main (int argc, char ** argv) { GtkWidget *menu = NULL; AppIndicator *ci = NULL; gtk_init (&argc, &argv); ci = app_indicator_new ("example-simple-client", "indicator-messages", APP_INDICATOR_CATEGORY_APPLICATION_STATUS); g_assert (IS_APP_INDICATOR (ci)); g_assert (G_IS_OBJECT (ci)); app_indicator_set_status (ci, APP_INDICATOR_STATUS_ACTIVE); app_indicator_set_attention_icon_full(ci, "indicator-messages-new", "System Messages Icon Highlighted"); app_indicator_set_label (ci, "1%", "100%"); app_indicator_set_title (ci, "Test Inidcator"); g_signal_connect (ci, "act", G_CALLBACK (scroll_event_cb), NULL); g_timeout_add_seconds(1, percent_change, ci); menu = gtk_menu_new (); GtkWidget *item = gtk_check_menu_item_new_with_label ("1"); g_signal_connect (item, "activate", G_CALLBACK (item_clicked_cb), "1"); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); item = gtk_radio_menu_item_new_with_label (NULL, "2"); g_signal_connect (item, "activate", G_CALLBACK (item_clicked_cb), "2"); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); item = gtk_menu_item_new_with_label ("3"); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); append_submenu (item); gtk_widget_show (item); GtkWidget *toggle_item = gtk_menu_item_new_with_label ("Toggle 3"); g_signal_connect (toggle_item, "activate", G_CALLBACK (toggle_sensitivity_cb), item); gtk_menu_shell_append (GTK_MENU_SHELL (menu), toggle_item); gtk_widget_show(toggle_item); item = gtk_image_menu_item_new_from_stock (GTK_STOCK_NEW, NULL); g_signal_connect (item, "activate", G_CALLBACK (image_clicked_cb), NULL); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show(item); item = gtk_menu_item_new_with_label ("Get Attention"); g_signal_connect (item, "activate", G_CALLBACK (activate_clicked_cb), ci); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show(item); app_indicator_set_secondary_activate_target(ci, item); item = gtk_menu_item_new_with_label ("Show label"); label_toggle_cb(item, ci); g_signal_connect (item, "activate", G_CALLBACK (label_toggle_cb), ci); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show(item); item = gtk_check_menu_item_new_with_label ("Set Local Icon"); g_signal_connect (item, "activate", G_CALLBACK (local_icon_toggle_cb), ci); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show(item); app_indicator_set_menu (ci, GTK_MENU (menu)); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); return 0; }
int main (int argc, char **argv) { GError *error = NULL; gboolean is_no_daemon = FALSE; gboolean is_debug = FALSE; gboolean is_version = FALSE; GOptionContext *context; GOptionEntry entries[] = { {"no-daemon", 0, 0, G_OPTION_ARG_NONE, &is_no_daemon, N_("Do not daemonize"), NULL}, {"debug", 0, 0, G_OPTION_ARG_NONE, &is_debug, N_("Log debugging message"), NULL}, {"version", 0, 0, G_OPTION_ARG_NONE, &is_version, N_("Version"), NULL}, {NULL} }; context = g_option_context_new ("- indicator for Nimf"); g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); g_option_context_parse (context, &argc, &argv, &error); g_option_context_free (context); if (error != NULL) { g_warning ("%s", error->message); g_error_free (error); return EXIT_FAILURE; } #ifdef ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, NIMF_LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif if (is_debug) g_setenv ("G_MESSAGES_DEBUG", "nimf", TRUE); if (is_version) { g_print ("%s %s\n", argv[0], VERSION); exit (EXIT_SUCCESS); } if (is_no_daemon == FALSE) { openlog (g_get_prgname (), LOG_PID | LOG_PERROR, LOG_DAEMON); syslog_initialized = TRUE; g_log_set_default_handler ((GLogFunc) nimf_log_default_handler, &is_debug); if (daemon (0, 0) != 0) { g_critical ("Couldn't daemonize."); return EXIT_FAILURE; } } gtk_init (&argc, &argv); AppIndicator *indicator; GtkWidget *menu_shell; GtkWidget *about_menu; GtkWidget *exit_menu; menu_shell = gtk_menu_new (); indicator = app_indicator_new ("nimf-indicator", "input-keyboard", APP_INDICATOR_CATEGORY_APPLICATION_STATUS); app_indicator_set_status (indicator, APP_INDICATOR_STATUS_ACTIVE); app_indicator_set_icon_full (indicator, "nimf-indicator", "Nimf"); app_indicator_set_menu (indicator, GTK_MENU (menu_shell)); agent = nimf_agent_new (); g_signal_connect (agent, "engine-changed", G_CALLBACK (on_engine_changed), indicator); g_signal_connect (agent, "disconnected", G_CALLBACK (on_disconnected), indicator); /* menu */ gchar **engine_ids = nimf_agent_get_loaded_engine_ids (agent); GtkWidget *engine_menu; NimfEngineInfo *info; guint i; for (i = 0; i < g_strv_length (engine_ids); i++) { info = nimf_engine_get_info_by_id (engine_ids[i]); engine_menu = gtk_menu_item_new_with_label (_(info->engine_name)); gtk_menu_shell_append (GTK_MENU_SHELL (menu_shell), engine_menu); g_signal_connect (engine_menu, "activate", G_CALLBACK (on_engine_menu), engine_ids[i]); g_slice_free (NimfEngineInfo, info); } about_menu = gtk_menu_item_new_with_label (_("About")); exit_menu = gtk_menu_item_new_with_label (_("Exit")); g_signal_connect (about_menu, "activate", G_CALLBACK (on_about_menu), NULL); g_signal_connect (exit_menu, "activate", G_CALLBACK (on_exit_menu), NULL); gtk_menu_shell_append (GTK_MENU_SHELL (menu_shell), about_menu); gtk_menu_shell_append (GTK_MENU_SHELL (menu_shell), exit_menu); gtk_widget_show_all (menu_shell); gtk_main (); g_object_unref (agent); g_object_unref (indicator); g_strfreev (engine_ids); if (syslog_initialized) closelog (); return EXIT_SUCCESS; }
void UnityIndicator::init() { GtkWidget *menu = gtk_menu_new(); GtkWidget *options = gtk_menu_item_new_with_label(qPrintable(tr("Settings"))); GtkWidget *reload = gtk_menu_item_new_with_label(qPrintable(tr("Refresh database"))); GtkWidget *backup = gtk_menu_item_new_with_label(qPrintable(tr("Backup Manager"))); GtkWidget *separator1 = gtk_separator_menu_item_new(); GtkWidget *about = gtk_menu_item_new_with_label(qPrintable(tr("About QCMA"))); GtkWidget *about_qt = gtk_menu_item_new_with_label(qPrintable(tr("About Qt"))); GtkWidget *separator2 = gtk_separator_menu_item_new(); GtkWidget *quit = gtk_menu_item_new_with_label(qPrintable(tr("Quit"))); gtk_menu_shell_append(GTK_MENU_SHELL(menu), options); gtk_menu_shell_append(GTK_MENU_SHELL(menu), reload); gtk_menu_shell_append(GTK_MENU_SHELL(menu), backup); gtk_menu_shell_append(GTK_MENU_SHELL(menu), separator1); gtk_menu_shell_append(GTK_MENU_SHELL(menu), about); gtk_menu_shell_append(GTK_MENU_SHELL(menu), about_qt); gtk_menu_shell_append(GTK_MENU_SHELL(menu), separator2); gtk_menu_shell_append(GTK_MENU_SHELL(menu), quit); gulong handle; handle = g_signal_connect(options, "activate", G_CALLBACK(optionsIndicator), this); m_handlers.append(QPair<gpointer, gulong>(options, handle)); handle = g_signal_connect(reload, "activate", G_CALLBACK(reloadIndicator), this); m_handlers.append(QPair<gpointer, gulong>(reload, handle)); handle = g_signal_connect(backup, "activate", G_CALLBACK(backupIndicator), this); m_handlers.append(QPair<gpointer, gulong>(backup, handle)); handle = g_signal_connect(about, "activate", G_CALLBACK(aboutIndicator), this); m_handlers.append(QPair<gpointer, gulong>(about, handle)); handle = g_signal_connect(about_qt, "activate", G_CALLBACK(aboutQtIndicator), this); m_handlers.append(QPair<gpointer, gulong>(about_qt, handle)); handle = g_signal_connect(quit, "activate", G_CALLBACK(quitIndicator), this); m_handlers.append(QPair<gpointer, gulong>(quit, handle)); gtk_widget_show(options); gtk_widget_show(reload); gtk_widget_show(backup); gtk_widget_show(separator1); gtk_widget_show(about); gtk_widget_show(about_qt); gtk_widget_show(separator2); gtk_widget_show(quit); m_indicator = app_indicator_new( "qcma-appindicator", "qcma-messages", APP_INDICATOR_CATEGORY_APPLICATION_STATUS ); QString icon_path; QString icon_name = "share/icons/hicolor/64x64/actions/qcma_on.png"; if(QFile("/usr/" + icon_name).exists()) icon_path = QFileInfo("/usr/" + icon_name).absolutePath(); else if(QFile("/usr/local" + icon_name).exists()) icon_path = QFileInfo("/usr/" + icon_name).absolutePath(); if(!icon_path.isEmpty()) { qDebug() << "Using " << icon_path << " as icon theme path"; app_indicator_set_icon_theme_path(m_indicator, qPrintable(icon_path)); } else qDebug() << "Cannot find qcma icons."; app_indicator_set_status(m_indicator, APP_INDICATOR_STATUS_ACTIVE); app_indicator_set_menu(m_indicator, GTK_MENU(menu)); }