static void remmina_applet_menu_increase_group_count(GtkWidget *widget) { gint cnt; gchar *s; cnt = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "count")) + 1; g_object_set_data(G_OBJECT(widget), "count", GINT_TO_POINTER(cnt)); s = g_strdup_printf("%s (%i)", (const gchar*) g_object_get_data(G_OBJECT(widget), "group"), cnt); gtk_menu_item_set_label(GTK_MENU_ITEM(widget), s); g_free(s); }
static void update_story(struct story *story) { GtkMenuItem *menu_item = GTK_MENU_ITEM(story->menu_item); gchar title[512]; g_snprintf(title, sizeof title, "%03u/%03u %s", story->points, story->num_comments, story->title); gtk_menu_item_set_label(menu_item, title); gtk_widget_set_tooltip_text(story->menu_item, story->description); gtk_widget_show(story->menu_item); }
static gboolean on_visibility_notify(GtkWidget* widget, GdkEvent* event, gpointer data) { GDateTime* datetime = g_date_time_new_now_local(); if(!datetime) { gtk_menu_item_set_label(GTK_MENU_ITEM(greeter.ui.clock.date_widget), "[date]"); g_signal_handler_disconnect(greeter.ui.clock.date_widget, visibility_notify_id); return TRUE; } gchar* str = g_date_time_format(datetime, config.clock.date_format); gtk_menu_item_set_label(GTK_MENU_ITEM(greeter.ui.clock.date_widget), str); gtk_calendar_select_month(GTK_CALENDAR(greeter.ui.clock.calendar_widget), g_date_time_get_month(datetime) - 1, g_date_time_get_year(datetime)); gtk_calendar_select_day(GTK_CALENDAR(greeter.ui.clock.calendar_widget), g_date_time_get_day_of_month(datetime)); g_free(str); g_date_time_unref(datetime); return TRUE; }
static void glide_window_update_undo_ui (GlideWindow *w) { GtkAction *undo_action, *redo_action; GtkMenuItem *undo_item, *redo_item; undo_action = GTK_ACTION (GLIDE_WINDOW_UI_OBJECT (w, "undo-action")); redo_action = GTK_ACTION (GLIDE_WINDOW_UI_OBJECT (w, "redo-action")); undo_item = GTK_MENU_ITEM (GLIDE_WINDOW_UI_OBJECT (w, "undo-menuitem")); redo_item = GTK_MENU_ITEM (GLIDE_WINDOW_UI_OBJECT (w, "redo-menuitem")); if (glide_undo_manager_get_can_undo (w->priv->undo_manager)) { gchar *label = g_strdup_printf("Undo: %s", glide_undo_manager_get_undo_label (w->priv->undo_manager)); gtk_action_set_sensitive (undo_action, TRUE); gtk_menu_item_set_label (undo_item, label); g_free (label); } else { gtk_action_set_sensitive (undo_action, FALSE); gtk_menu_item_set_label (undo_item, "Undo"); } if (glide_undo_manager_get_can_redo (w->priv->undo_manager)) { gchar *label = g_strdup_printf("Redo: %s", glide_undo_manager_get_redo_label (w->priv->undo_manager)); gtk_action_set_sensitive (redo_action, TRUE); gtk_menu_item_set_label (redo_item, label); g_free (label); } else { gtk_action_set_sensitive (redo_action, FALSE); gtk_menu_item_set_label (redo_item, "Redo"); } }
// runs in main thread, should always return FALSE to prevent gtk to execute it again gboolean do_add_or_update_menu_item(gpointer data) { MenuItemInfo *mii = (MenuItemInfo*)data; GList* it; for(it = global_menu_items; it != NULL; it = it->next) { MenuItemNode* item = (MenuItemNode*)(it->data); if(item->menu_id == mii->menu_id){ gtk_menu_item_set_label(GTK_MENU_ITEM(item->menu_item), mii->title); if(mii->checkable == 1) { gtk_check_menu_item_set_active((GtkCheckMenuItem*)(item->menu_item), mii->checked == 1); } break; } } // menu id doesn't exist, add new item if(it == NULL) { GtkWidget *menu_item; int *id = malloc(sizeof(int)); *id = mii->menu_id; if(mii->checkable) { menu_item = gtk_check_menu_item_new_with_label(mii->title); gtk_check_menu_item_set_active((GtkCheckMenuItem*)(menu_item), mii->checked == 1); g_signal_connect_swapped(G_OBJECT(menu_item), "toggled", G_CALLBACK(_systray_menu_item_changed), id); } else { menu_item = gtk_menu_item_new_with_label(mii->title); g_signal_connect_swapped(G_OBJECT(menu_item), "activate", G_CALLBACK(_systray_menu_item_selected), id); } gtk_menu_shell_append(GTK_MENU_SHELL(global_tray_menu), menu_item); MenuItemNode* new_item = malloc(sizeof(MenuItemNode)); new_item->menu_id = mii->menu_id; new_item->menu_item = menu_item; GList* new_node = malloc(sizeof(GList)); new_node->data = new_item; new_node->next = global_menu_items; if(global_menu_items != NULL) { global_menu_items->prev = new_node; } global_menu_items = new_node; it = new_node; } GtkWidget * menu_item = GTK_WIDGET(((MenuItemNode*)(it->data))->menu_item); gtk_widget_set_sensitive(menu_item, mii->disabled == 1 ? FALSE : TRUE); gtk_widget_show(menu_item); free(mii->title); free(mii->tooltip); free(mii); return FALSE; }
static void pocketvox_indicator_state_changed(GtkMenuItem *menuitem, gpointer user_data) { PocketvoxIndicator *indicator = (PocketvoxIndicator *)user_data; indicator->priv = G_TYPE_INSTANCE_GET_PRIVATE (indicator, TYPE_POCKETVOX_INDICATOR, PocketvoxIndicatorPrivate); PocketvoxIndicatorPrivate *priv = indicator->priv; priv->state = !priv->state; gtk_menu_item_set_label(menuitem, priv->state ? _("Stop") : _("Run")); g_signal_emit(indicator, pocketvox_indicator_signals[INDICATOR_STATE], 0, priv->state ? "Run" : "Stop"); }
static gboolean update_status (DrWright *dr) { gint min; gchar *str; #ifdef HAVE_APP_INDICATOR GtkWidget *item; #endif /* HAVE_APP_INDICATOR */ if (!dr->enabled) { #ifdef HAVE_APP_INDICATOR app_indicator_set_status (dr->indicator, APP_INDICATOR_STATUS_PASSIVE); #else gtk_status_icon_set_tooltip_text (dr->icon, _("Disabled")); #endif /* HAVE_APP_INDICATOR */ return TRUE; } min = get_time_left (dr); if (min >= 1) { #ifdef HAVE_APP_INDICATOR str = g_strdup_printf (_("Take a break now (next in %dm)"), min); #else str = g_strdup_printf (ngettext("%d minute until the next break", "%d minutes until the next break", min), min); #endif /* HAVE_APP_INDICATOR */ } else { #ifdef HAVE_APP_INDICATOR str = g_strdup_printf (_("Take a break now (next in less than one minute)")); #else str = g_strdup_printf (_("Less than one minute until the next break")); #endif /* HAVE_APP_INDICATOR */ } #ifdef HAVE_APP_INDICATOR item = gtk_ui_manager_get_widget (dr->ui_manager, "/Pop/TakeABreak"); gtk_menu_item_set_label (GTK_MENU_ITEM (item), str); #else gtk_status_icon_set_tooltip_text (dr->icon, str); #endif /* HAVE_APP_INDICATOR */ g_free (str); return TRUE; }
/** * mute_widget_new: * @returns: a new #MuteWidget. **/ MuteWidget * mute_widget_new (DbusmenuMenuitem *item) { MuteWidget* widget = g_object_new(MUTE_WIDGET_TYPE, NULL); MuteWidgetPrivate* priv = MUTE_WIDGET_GET_PRIVATE(widget); priv->item = g_object_ref(item); GVariant *label = dbusmenu_menuitem_property_get_variant(priv->item, DBUSMENU_MENUITEM_PROP_LABEL); if (g_variant_is_of_type(label, G_VARIANT_TYPE_STRING)) gtk_menu_item_set_label(priv->gitem, g_variant_get_string(label, NULL)); return widget; }
static void panel_menu_bar_init(PanelMenuBar* menubar) { #if GTK_CHECK_VERSION (3, 0, 0) GtkCssProvider *provider; #endif menubar->priv = PANEL_MENU_BAR_GET_PRIVATE(menubar); #if GTK_CHECK_VERSION (3, 0, 0) provider = gtk_css_provider_new (); gtk_css_provider_load_from_data (provider, "PanelMenuBar {\n" " border-width: 0px;\n" "}", -1, NULL); gtk_style_context_add_provider (gtk_widget_get_style_context (GTK_WIDGET (menubar)), GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); g_object_unref (provider); #endif menubar->priv->info = NULL; menubar->priv->settings = g_settings_new (PANEL_MENU_BAR_SCHEMA); menubar->priv->applications_menu = create_applications_menu("mate-applications.menu", NULL, TRUE); menubar->priv->applications_item = panel_image_menu_item_new(); gtk_menu_item_set_label(GTK_MENU_ITEM(menubar->priv->applications_item), _("Applications")); gtk_menu_item_set_submenu(GTK_MENU_ITEM(menubar->priv->applications_item), menubar->priv->applications_menu); gtk_menu_shell_append(GTK_MENU_SHELL(menubar), menubar->priv->applications_item); menubar->priv->places_item = panel_place_menu_item_new(FALSE); gtk_menu_shell_append(GTK_MENU_SHELL(menubar), menubar->priv->places_item); menubar->priv->desktop_item = panel_desktop_menu_item_new(FALSE, TRUE); gtk_menu_shell_append(GTK_MENU_SHELL(menubar), menubar->priv->desktop_item); panel_menu_bar_setup_tooltip(menubar); panel_menu_bar_update_visibility(menubar->priv->settings, NULL, menubar); g_signal_connect(menubar->priv->settings, "changed", G_CALLBACK (panel_menu_bar_update_visibility), menubar); panel_menu_bar_update_text_gravity(menubar); g_signal_connect(menubar, "screen-changed", G_CALLBACK(panel_menu_bar_update_text_gravity), NULL); }
void menu_info_subitem_update(menu_info_t* mi, uint32_t index, const char* name, const char* desc, char* tooltip, const char* icon) { menu_info_item_t* item = menu_info_item_get(mi, index); if(item == NULL) g_error("[menu_info] subitem not found!"); gboolean active = mi->parent->target == index; g_debug("[menu_info] updating subitem %s %u '%s' %s", menu_info_type_name(mi->type), index, desc, active ? " (active)" : ""); if(!g_str_equal(item->desc, desc)) gtk_menu_item_set_label(GTK_MENU_ITEM(item->widget), desc); if(active) gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item->widget), TRUE); }
static void appendMenuItem(GtkMenuShell *submenu, uiMenuItem *item, uiWindow *w) { GtkWidget *menuitem; gulong signal; struct menuItemWindow *ww; menuitem = g_object_new(item->gtype, NULL); if (item->name != NULL) gtk_menu_item_set_label(GTK_MENU_ITEM(menuitem), item->name); if (item->type != typeSeparator) { signal = g_signal_connect(menuitem, "activate", G_CALLBACK(onClicked), item); gtk_widget_set_sensitive(menuitem, !item->disabled); if (item->type == typeCheckbox) singleSetChecked(GTK_CHECK_MENU_ITEM(menuitem), item->checked, signal); } gtk_menu_shell_append(submenu, menuitem); ww = uiNew(struct menuItemWindow); ww->w = w; ww->signal = signal; g_hash_table_insert(item->windows, menuitem, ww); }
void on_status ( OrgZlbruceEyerestBasic *object, guint arg_time_remain, const gchar *arg_state) { time_t time_remain = arg_time_remain; static gchar time_str[PATH_MAX]; struct tm* tm = localtime(&time_remain); int len = 0; if(tm == NULL) { len = g_snprintf(time_str, sizeof(time_str), "%lu", (unsigned long)time); } else { len = strftime(time_str, sizeof(time_str), "%M:%S", tm); } //g_printf("time_str = %s, state = %s\n", time_str, arg_state); gtk_menu_item_set_label(GTK_MENU_ITEM(menu_item_state), time_str); gtk_status_icon_set_tooltip_text (tray_icon, time_str); if(arg_time_remain < 60) { if(!g_notified) { send_notification(time_str, arg_time_remain); } } else { g_notified = FALSE; if(g_notify_id != 0) { close_notification(); } } }
static void update_labels(void) { gchar *label; label = g_strdup_printf(_("Default (%s)"), (sc_info->default_language != NULL) ? sc_info->default_language : _("unknown")); gtk_menu_item_set_label(GTK_MENU_ITEM(sc_info->submenu_item_default), label); g_free(label); #if GTK_CHECK_VERSION(2, 12, 0) if (sc_info->toolbar_button != NULL) { gchar *text = g_strdup_printf( _("Toggle spell check while typing (current language: %s)"), (sc_info->default_language != NULL) ? sc_info->default_language : _("unknown")); gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(sc_info->toolbar_button), text); g_free(text); } #endif }
void on_status ( OrgZlbruceEyerestBasic *object, guint arg_time_remain, const gchar *arg_state) { time_t time_remain = arg_time_remain; static gchar time_str[PATH_MAX]; struct tm* tm = localtime(&time_remain); if(tm == NULL) { g_snprintf(time_str, sizeof(time_str), "%lu", (unsigned long)time); } else { strftime(time_str, sizeof(time_str), "%M:%S", tm); } //g_printf("time_str = %s, state = %s\n", time_str, arg_state); gtk_menu_item_set_label(GTK_MENU_ITEM(menu_item_state), time_str); gtk_status_icon_set_tooltip_text (tray_icon, time_str); }
void update_tray(void) { GtkMenuItem *menu_cal; gchar *icon_name, *today_text; menu_cal = GTK_MENU_ITEM(gtk_builder_get_object(builder, "menu_cal")); icon_name = g_strdup_printf("acal-%s-%d", g_settings_get_boolean(settings, "dark-icon") ? "dark" : "light", today.tm_mday); /* set tray icon */ app_indicator_set_icon_full(indicator, icon_name, icon_name); g_free(icon_name); /* set menu_cal text */ today_text = g_strdup_printf("%s %s %s %s", gettext(day[today.tm_wday]), persian_digit(today.tm_mday), gettext(mon[today.tm_mon]), persian_digit(today.tm_year)); gtk_menu_item_set_label(menu_cal, today_text); g_free(today_text); }
static void popup_menu (GtkStatusIcon *status_icon, guint button, guint activate_time, gpointer user_data) { if (!menu) { GtkWidget *item; menu = gtk_menu_new (); item = gtk_image_menu_item_new_from_stock (GTK_STOCK_CLOSE, NULL); gtk_menu_item_set_label (GTK_MENU_ITEM (item), "Close Fortunes"); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (close_notifications), NULL); item = gtk_image_menu_item_new_from_stock (GTK_STOCK_ABOUT, NULL); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (show_about_dialog), NULL); item = gtk_image_menu_item_new_from_stock (GTK_STOCK_QUIT, NULL); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (destroy), NULL); } gtk_widget_show_all (menu); gtk_menu_popup (GTK_MENU (menu), NULL, NULL, gtk_status_icon_position_menu, status_icon, button, activate_time); }
void pMenu::setText(const string &text) { gtk_menu_item_set_label(GTK_MENU_ITEM(widget), mnemonic(text)); }
void menu_info_item_update(menu_info_t* mi, uint32_t index, const char* name, const char* desc, const pa_cvolume* vol, int mute, char* tooltip, const char* icon, const char* address) { menu_info_item_t* mii; if(mi->type == MENU_SERVER) mii = menu_info_item_get_by_name(mi, name); else mii = menu_info_item_get(mi, index); if(mii == NULL) return menu_info_item_add(mi, index, name, desc, vol, mute, tooltip, icon, address); #ifdef DEBUG g_message("[menu_info] updating %s %u %s", menu_info_type_name(mii->menu_info->type), index, desc); #endif g_free(mii->name); mii->name = g_strdup(name); g_free(mii->desc); mii->desc = g_strdup(desc); g_free(mii->volume); mii->volume = g_memdup(vol, sizeof(pa_cvolume)); mii->mute = mute; g_free(mii->address); mii->address = g_strdup(address); switch(mi->type) { case MENU_SERVER: case MENU_SINK: case MENU_SOURCE: gtk_menu_item_set_label(GTK_MENU_ITEM(mii->widget), desc); systray_set_tooltip(GTK_WIDGET(mii->widget), tooltip); // submenu to update (if any) menu_info_t* submenu = NULL; switch(mi->type) { case MENU_SINK: submenu = &mi->menu_infos->menu_info[MENU_INPUT]; break; case MENU_SOURCE: submenu = &mi->menu_infos->menu_info[MENU_OUTPUT]; break; default: break; } // change labels in stream submenus if(submenu) { GHashTableIter iter; gpointer key; menu_info_item_t* item; menu_info_item_t* subitem; g_hash_table_iter_init(&iter, submenu->items); while(g_hash_table_iter_next(&iter, &key, (gpointer*)&item)) if((subitem = g_hash_table_lookup(item->submenu->items, GUINT_TO_POINTER(mii->index)))) if(!g_str_equal(subitem->desc, desc)) gtk_menu_item_set_label( GTK_MENU_ITEM(subitem->widget), desc); } break; case MENU_INPUT: case MENU_OUTPUT: gtk_menu_item_set_label(GTK_MENU_ITEM(mii->widget), desc); systray_set_tooltip(GTK_WIDGET(mii->widget), tooltip); break; } /* if this is the default sink, update status icon acording to volume */ if(mi->type == MENU_SINK && mii == menu_info_item_get_by_name(mi, mi->default_name)) ui_update_statusicon(mii); }
void keybinds_conf_load (void) { FILE *fpConfig; char ConfFilePath [512]; char Getline[512]; char Mod[2]; char *pBuff = NULL; #ifdef __linux__ sprintf(ConfFilePath ,"%s/keybinds.ini" ,DirConf); #elif __WIN32 sprintf(ConfFilePath ,"%s\\keybinds.ini" ,DirConf); #endif fpConfig = fopen(ConfFilePath , "r"); if (fpConfig == NULL) { log_error(true,"**Warning: Couldn't load config file 'keybinds.ini' - Using defaults."); keybinds_conf_create (); return; } #ifdef __linux__ keybinder_unbind_all(Hotkey_FUP); keybinder_unbind_all(Hotkey_SS_A_UP); keybinder_unbind_all(Hotkey_SS_W_UP); keybinder_unbind_all(Hotkey_SS_F_UP); keybinder_unbind_all(Hotkey_SS_A_CAP); keybinder_unbind_all(Hotkey_SS_W_CAP); keybinder_unbind_all(Hotkey_SS_F_CAP); keybinder_unbind_all(Hotkey_OPEN); #elif _WIN32 int i; for ( i = 0 ; i < HOTKEY_COUNT ; ++i) UnregisterHotKey(hWndGTK, 200+i); #endif while(fgets (Getline , 512 , fpConfig) != NULL) { if(strncmp(Getline, "Hotkey_FUP" , strlen("Hotkey_FUP")) == 0) { pBuff = strstr(Getline , "="); pBuff += 2; snprintf(Hotkey_FUP, strlen(pBuff),"%s",pBuff); } else if(strncmp(Getline, "Hotkey_SS_A_UP" , strlen("Hotkey_SS_A_UP")) == 0) { pBuff = strstr(Getline , "="); pBuff += 2; snprintf(Hotkey_SS_A_UP,strlen(pBuff),"%s",pBuff); } else if(strncmp(Getline, "Hotkey_SS_W_UP" , strlen("Hotkey_SS_W_UP")) == 0) { pBuff = strstr(Getline , "="); pBuff += 2; snprintf(Hotkey_SS_W_UP,strlen(pBuff),"%s",pBuff); } else if(strncmp(Getline, "Hotkey_SS_F_UP" , strlen("Hotkey_SS_F_UP")) == 0) { pBuff = strstr(Getline , "="); pBuff += 2; snprintf(Hotkey_SS_F_UP,strlen(pBuff),"%s",pBuff); } else if(strncmp(Getline, "Hotkey_SS_A_CAP" , strlen("Hotkey_SS_A_CAP")) == 0) { pBuff = strstr(Getline , "="); pBuff += 2; snprintf(Hotkey_SS_A_CAP,strlen(pBuff),"%s",pBuff); } else if(strncmp(Getline, "Hotkey_SS_W_CAP" , strlen("Hotkey_SS_W_CAP")) == 0) { pBuff = strstr(Getline , "="); pBuff += 2; snprintf(Hotkey_SS_W_CAP,strlen(pBuff),"%s",pBuff); } else if(strncmp(Getline, "Hotkey_SS_F_CAP" , strlen("Hotkey_SS_F_CAP")) == 0) { pBuff = strstr(Getline , "="); pBuff += 2; snprintf(Hotkey_SS_F_CAP,strlen(pBuff),"%s",pBuff); } else if(strncmp(Getline, "Hotkey_OPEN" , strlen("Hotkey_OPEN")) == 0) { pBuff = strstr(Getline , "="); pBuff += 2; snprintf(Hotkey_OPEN,strlen(pBuff),"%s",pBuff); } else if(strncmp(Getline, "Enable_HK_FUP" , strlen("Enable_HK_FUP")) == 0) { pBuff = strstr(Getline , "="); pBuff += 2; strncpy(Mod,pBuff,1); bHotkey_FUP = atoi(Mod); } else if(strncmp(Getline, "Enable_HK_SS_A_UP" , strlen("Enable_HK_SS_A_UP")) == 0) { pBuff = strstr(Getline , "="); pBuff += 2; strncpy(Mod,pBuff,1); bHotkey_SS_A_UP = atoi(Mod); } else if(strncmp(Getline, "Enable_HK_SS_W_UP" , strlen("Enable_HK_SS_W_UP")) == 0) { pBuff = strstr(Getline , "="); pBuff += 2; strncpy(Mod,pBuff,1); bHotkey_SS_W_UP = atoi(Mod); } else if(strncmp(Getline, "Enable_HK_SS_F_UP" , strlen("Enable_HK_SS_F_UP")) == 0) { pBuff = strstr(Getline , "="); pBuff += 2; strncpy(Mod,pBuff,1); bHotkey_SS_F_UP = atoi(Mod); } else if(strncmp(Getline, "Enable_HK_SS_A_CAP" , strlen("Enable_HK_SS_A_CAP")) == 0) { pBuff = strstr(Getline , "="); pBuff += 2; strncpy(Mod,pBuff,1); bHotkey_SS_A_CAP = atoi(Mod); } else if(strncmp(Getline, "Enable_HK_SS_W_CAP" , strlen("Enable_HK_SS_W_CAP")) == 0) { pBuff = strstr(Getline , "="); pBuff += 2; strncpy(Mod,pBuff,1); bHotkey_SS_W_CAP = atoi(Mod); } else if(strncmp(Getline, "Enable_HK_SS_F_CAP" , strlen("Enable_HK_SS_F_CAP")) == 0) { pBuff = strstr(Getline , "="); pBuff += 2; strncpy(Mod,pBuff,1); bHotkey_SS_F_CAP = atoi(Mod); } else if(strncmp(Getline, "Enable_HK_OPEN" , strlen("Enable_HK_OPEN")) == 0) { pBuff = strstr(Getline , "="); pBuff += 2; strncpy(Mod,pBuff,1); bHotkey_OPEN = atoi(Mod); } } pBuff = NULL; fclose(fpConfig); #ifdef __linux__ char MenuLabel[128]; if(bHotkey_FUP) { keybinder_bind_full(Hotkey_FUP, file_chooser_start, NULL, NULL); sprintf(MenuLabel,"Upload File(s)\t\t%s",Hotkey_FUP ); gtk_menu_item_set_label ( GTK_MENU_ITEM(menuFileUp), MenuLabel); } else gtk_menu_item_set_label ( GTK_MENU_ITEM(menuFileUp), "Upload File"); if (bHotkey_SS_A_UP) { keybinder_bind_full(Hotkey_SS_A_UP, take_screenshot, (void*)1, NULL); sprintf(MenuLabel,"Capture Area & UP\t%s", Hotkey_SS_A_UP); gtk_menu_item_set_label (GTK_MENU_ITEM(menuCapUp), MenuLabel); } else gtk_menu_item_set_label (GTK_MENU_ITEM(menuCapUp), "Capture Area & UP"); if (bHotkey_SS_W_UP) keybinder_bind_full(Hotkey_SS_W_UP, take_screenshot, (void*)2, NULL); if (bHotkey_SS_F_UP) keybinder_bind_full(Hotkey_SS_F_UP, take_screenshot, (void*)3, NULL); if (bHotkey_SS_A_CAP) { keybinder_bind_full(Hotkey_SS_A_CAP, take_screenshot, (void*)4, NULL); sprintf(MenuLabel,"Capture Area\t\t%s", Hotkey_SS_A_CAP); gtk_menu_item_set_label (GTK_MENU_ITEM(menuCap) , MenuLabel); } else gtk_menu_item_set_label (GTK_MENU_ITEM(menuCap) , "Capture Area"); if (bHotkey_SS_W_CAP) keybinder_bind_full(Hotkey_SS_W_CAP, take_screenshot, (void*)5, NULL); if (bHotkey_SS_F_CAP) keybinder_bind_full(Hotkey_SS_F_CAP, take_screenshot, (void*)6, NULL); if (bHotkey_OPEN) { keybinder_bind_full(Hotkey_OPEN, pomfit_open_links, NULL, NULL); sprintf(MenuLabel,"Open URL(s)\t\t%s", Hotkey_OPEN); gtk_menu_item_set_label (GTK_MENU_ITEM(menuOpen) , MenuLabel); } else gtk_menu_item_set_label (GTK_MENU_ITEM(menuOpen) , "Open URL(s)"); #elif _WIN32 /* Win Key Code { 0, 2, 1, 4, 8} NULL , ALT , CTRL , SHIFT , WIN */ int len; int Key[HOTKEY_COUNT] ; int Modes[HOTKEY_COUNT][2]; char Bind[HOTKEY_COUNT][64]; strcpy(Bind[0],Hotkey_FUP); strcpy(Bind[1],Hotkey_SS_A_UP); strcpy(Bind[2],Hotkey_SS_W_UP); strcpy(Bind[3],Hotkey_SS_F_UP); strcpy(Bind[4],Hotkey_SS_A_CAP); strcpy(Bind[5],Hotkey_SS_W_CAP); strcpy(Bind[6],Hotkey_SS_F_CAP); strcpy(Bind[7],Hotkey_OPEN); for (i = 0 ; i < HOTKEY_COUNT ; ++i) { len = strlen(Bind[i]); Key[i] = Bind[i][len-1]; pBuff = strtok(Bind[i], ">"); if(pBuff != NULL) { if(pBuff[1] == 'C') Modes[i][0] = 2; else if (pBuff[1] == 'S') Modes[i][0] = 4; else if (pBuff[1] == 'A') Modes[i][0] = 1; else if (pBuff[1] == 'W') Modes[i][0] = 8; else Modes[i][0] = 0; } else continue; pBuff = strtok(NULL, ">"); if(pBuff != NULL) { if(pBuff[1] == 'C') Modes[i][1] = 2; else if (pBuff[1] == 'S') Modes[i][1] = 4; else if (pBuff[1] == 'A') Modes[i][1] = 1; else if (pBuff[1] == 'W') Modes[i][1] = 8; else Modes[i][1] = 0; } } pBuff = NULL; if(bHotkey_FUP) RegisterHotKey(hWndGTK, HOTKEY_FILEUP, Modes[0][1] | Modes[0][0], Key[0]); if (bHotkey_SS_A_UP) RegisterHotKey(hWndGTK, HOTKEY_AREA_SS_UP, Modes[1][1] | Modes[1][0], Key[1]); if (bHotkey_SS_W_UP) RegisterHotKey(hWndGTK, HOTKEY_WIN_SS_UP, Modes[2][1] | Modes[2][0], Key[2]); if (bHotkey_SS_F_UP) RegisterHotKey(hWndGTK, HOTKEY_FULL_SS_UP, Modes[3][1] | Modes[3][0], Key[3]); if (bHotkey_SS_A_CAP) RegisterHotKey(hWndGTK, HOTKEY_AREA_SS_CAP, Modes[4][1] | Modes[4][0], Key[4]); if (bHotkey_SS_W_CAP) RegisterHotKey(hWndGTK, HOTKEY_WIN_SS_CAP, Modes[5][1] | Modes[5][0], Key[5]); if (bHotkey_SS_F_CAP) RegisterHotKey(hWndGTK, HOTKEY_FULL_SS_CAP, Modes[6][1] | Modes[6][0], Key[6]); if (bHotkey_OPEN) RegisterHotKey(hWndGTK, HOTKEY_OPEN, Modes[7][1] | Modes[7][0], Key[7]); #endif }
GtkMenu* create_menu(struct _tray_icon *tray, int state) { if (state) {}; GtkMenu *menu = GTK_MENU(gtk_menu_new()); GtkWidget *menuitem; GtkWidget *image; // Start/stop gchar *status_text; int xneur_pid = xconfig->get_pid(xconfig); if (xneur_pid != -1) { status_text = g_strdup_printf("%s", _("Stop daemon")); } else { status_text = g_strdup_printf("%s", _("Start daemon")); } xneur_old_pid = xneur_pid; if (tray->status == NULL) { tray->status = gtk_menu_item_new_with_mnemonic(status_text); gtk_widget_show(tray->status); gtk_container_add(GTK_CONTAINER(menu), tray->status); g_signal_connect(G_OBJECT(tray->status), "activate", G_CALLBACK(xneur_start_stop), tray); } else { gtk_menu_item_set_label(GTK_MENU_ITEM(tray->status), status_text); } g_free(status_text); // Separator menuitem = gtk_separator_menu_item_new(); gtk_widget_show(menuitem); gtk_container_add(GTK_CONTAINER(menu), menuitem); gtk_widget_set_sensitive(menuitem, FALSE); // User Actions Submenu GtkWidget *action_submenu = gtk_menu_new(); for (int action = 0; action < xconfig->actions_count; action++) { menuitem = gtk_menu_item_new_with_mnemonic(xconfig->actions[action].name); gtk_widget_show(menuitem); g_signal_connect_swapped(G_OBJECT(menuitem), "activate", G_CALLBACK(exec_user_action), xconfig->actions[action].command); gtk_container_add(GTK_CONTAINER(action_submenu), menuitem); } menuitem = gtk_image_menu_item_new_with_mnemonic(_("User action")); image = gtk_image_new_from_stock("gtk-execute", GTK_ICON_SIZE_MENU); gtk_widget_set_name(image, "image"); gtk_widget_show(image); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image); gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), action_submenu); gtk_widget_show(menuitem); gtk_container_add(GTK_CONTAINER(menu), menuitem); if (xconfig->actions_count < 1) gtk_widget_set_sensitive(menuitem, FALSE); // View log menuitem = gtk_menu_item_new_with_mnemonic(_("View log...")); gtk_widget_show(menuitem); gtk_container_add(GTK_CONTAINER(menu), menuitem); g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(xneur_get_logfile), tray); // Separator menuitem = gtk_separator_menu_item_new(); gtk_widget_show(menuitem); gtk_container_add(GTK_CONTAINER(menu), menuitem); gtk_widget_set_sensitive(menuitem, FALSE); // Preference menuitem = gtk_image_menu_item_new_from_stock("gtk-preferences", NULL); gtk_widget_show(menuitem); gtk_container_add(GTK_CONTAINER(menu), menuitem); g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(xneur_preference), tray); // Keyboard Preference menuitem = gtk_menu_item_new_with_mnemonic(_("Keyboard Properties")); gtk_widget_show(menuitem); gtk_container_add(GTK_CONTAINER(menu), menuitem); g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(xneur_kb_preference), tray); // About menuitem = gtk_image_menu_item_new_from_stock("gtk-about", NULL); gtk_widget_show(menuitem); gtk_container_add(GTK_CONTAINER(menu), menuitem); g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(xneur_about), tray); // Exit menuitem = gtk_image_menu_item_new_from_stock("gtk-quit", NULL); gtk_widget_show(menuitem); gtk_container_add(GTK_CONTAINER(menu), menuitem); g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(xneur_exit), tray); //gtk_widget_show (GTK_WIDGET(menu)); return GTK_MENU(menu); }
gboolean clock_check(gpointer dummy) { if (dummy) {}; int xneur_pid = -1; char *ps_command = (char *) malloc(1024 * sizeof(char)); if (xneur_old_pid == -1) xneur_old_pid = 1; snprintf(ps_command, 1024, "ps -p %d | grep xneur", xneur_old_pid); FILE *fp = popen(ps_command, "r"); free (ps_command); if (fp != NULL) { char buffer[NAME_MAX]; if (fgets(buffer, NAME_MAX, fp) != NULL) xneur_pid = xneur_old_pid; pclose(fp); } if (xneur_pid == -1) xneur_pid = xconfig->get_pid(xconfig); int xneur_state = xconfig->manual_mode; int xneur_group = get_active_kbd_group(dpy); if (get_kbd_group_count(dpy) != xconfig->handle->total_languages) { for (int i = 0; i < MAX_LAYOUTS; i++) { if (tray->images[i] != NULL) g_free(tray->images[i]); } gtk_widget_destroy(GTK_WIDGET(tray->menu)); tray->menu = NULL; g_spawn_command_line_async(PACKAGE, NULL); gtk_main_quit(); } if (xneur_pid == xneur_old_pid && xneur_state == xneur_old_state && xneur_group == xneur_old_group && force_update == FALSE) return TRUE; force_update = FALSE; xneur_old_pid = xneur_pid; xneur_old_state = xneur_state; xneur_old_group = xneur_group; int lang = get_active_kbd_group(dpy); gchar *hint; gchar *status_text; //float saturation = 1.0; if (xneur_pid != -1) { //saturation = 1.0; hint = g_strdup_printf("%s%s%s", _("X Neural Switcher running ("), xconfig->handle->languages[lang].dir, ")"); status_text = g_strdup_printf("%s", _("Stop daemon")); } else { //saturation = 0.25; hint = g_strdup_printf("%s%s%s", _("X Neural Switcher stopped ("), xconfig->handle->languages[lang].dir, ")"); status_text = g_strdup_printf("%s", _("Start daemon")); } gtk_menu_item_set_label(GTK_MENU_ITEM(tray->status), status_text); gint kbd_gr = get_active_kbd_group(dpy); const char *icon_name = get_tray_icon_name(tray->images[kbd_gr]); if (tray->tray_icon) { gtk_widget_hide_all(GTK_WIDGET(tray->tray_icon)); gtk_widget_destroy (tray->image); 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(icon_name, GTK_ICON_SIZE_LARGE_TOOLBAR); } gtk_container_add(GTK_CONTAINER(tray->evbox), tray->image); gtk_widget_show_all(GTK_WIDGET(tray->tray_icon)); } else if (tray->status_icon) { if (gtk_status_icon_is_embedded(tray->status_icon)) { 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, icon_name); } gtk_status_icon_set_tooltip(tray->status_icon, hint); } } #ifdef HAVE_APP_INDICATOR else if (tray->app_indicator) { char *layout_name = strdup(xconfig->handle->languages[kbd_gr].name); if (strcasecmp(show_in_the_tray, "Text") == 0) { #ifdef HAVE_DEPREC_APP_INDICATOR app_indicator_set_icon (tray->app_indicator, icon_name); #else app_indicator_set_label (tray->app_indicator, layout_name, layout_name); app_indicator_set_icon (tray->app_indicator, ""); #endif } else { #ifdef HAVE_DEPREC_APP_INDICATOR app_indicator_set_icon (tray->app_indicator, icon_name); #else app_indicator_set_icon (tray->app_indicator, icon_name); app_indicator_set_label (tray->app_indicator,"", ""); #endif } free(layout_name); } #endif g_free (hint); g_free (status_text); return TRUE; }
static gboolean gtkdial_signal_emission_hook(GSignalInvocationHint *ihint, guint n_param_values, const GValue *param_values, gpointer data) { GObject *p = G_OBJECT(g_value_peek_pointer(param_values+0)); GtkMenu *m = GTK_MENU(g_value_peek_pointer(param_values+1)); GtkClipboard *c = gtk_clipboard_get(GDK_SELECTION_PRIMARY); GObject *o = gtk_clipboard_get_owner(c); GtkTextBuffer *b = GTK_IS_TEXT_VIEW(p) ? gtk_text_view_get_buffer(GTK_TEXT_VIEW(p)) : NULL; const gchar *text = NULL; int out[3]; if (o && (p == o || (gpointer)b == o)) { /* text is local; should be fast */ text = gtk_clipboard_wait_for_text(c); } else if (GTK_IS_ENTRY(p)) { text = gtk_entry_get_text(GTK_ENTRY(p)); } else if (GTK_IS_LABEL(p)) { text = gtk_label_get_label(GTK_LABEL(p)); } if (text != NULL && pcre_exec(regexp_phone, regexp_phone_extra, text, strlen(text), 0, 0, out, 3) && out[1] > out[0]) { gchar *label; int need, len = out[1] - out[0]; const char *str = text + out[0]; free(last_phone_number); last_phone_number = NULL; if ((need = gtkdial_make_canonical(NULL, str, len)) > 1) { last_phone_number = malloc(1 + need); gtkdial_make_canonical(last_phone_number, str, len); last_phone_number[need] = '\0'; } if (last_phone_number != NULL && asprintf(&label, "Dial: %s", last_phone_number)) { GtkIconSet *icon_set = gtk_style_lookup_icon_set(gtk_widget_get_style(GTK_WIDGET(m)), "call-start"); GtkImageMenuItem *item; GtkImage *icon; if (!icon_set) { icon = GTK_IMAGE(gtk_image_new_from_file("/usr/share/icons/gnome-human/16x16/actions/call-start.png")); } else { icon = GTK_IMAGE(gtk_image_new_from_icon_set(icon_set, GTK_ICON_SIZE_MENU)); } item = GTK_IMAGE_MENU_ITEM(gtk_image_menu_item_new()); gtk_image_menu_item_set_image(item, GTK_WIDGET(icon)); gtk_menu_item_set_label(GTK_MENU_ITEM(item), label); free(label); g_signal_connect(G_OBJECT(item), "activate", (void*)gtkdial_doit, NULL); gtk_widget_show(GTK_WIDGET(item)); gtk_menu_prepend(m, GTK_WIDGET(item)); } } return TRUE; }
gboolean ui_callback_on_select_signal(GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path, gboolean path_currently_selected, gpointer user_data) { static gpointer buffer_current; ui_text_view_t *text_view; GtkTreeIter iter; g_debug("Message selected %d %p %p %s", path_currently_selected, buffer_current, path, gtk_tree_path_to_string(path)); if (!path_currently_selected) { text_view = (ui_text_view_t *) user_data; g_assert(text_view != NULL); if (gtk_tree_model_get_iter (model, &iter, path)) { gpointer buffer; uint32_t message_number; uint32_t message_id; uint32_t origin_task_id; uint32_t destination_task_id; char *instance_name; uint32_t instance; char label[100]; gtk_tree_model_get (model, &iter, COL_MSG_NUM, &message_number, COL_MESSAGE_ID, &message_id, COL_FROM_TASK_ID, &origin_task_id, COL_TO_TASK_ID, &destination_task_id, COL_INSTANCE, &instance_name, COL_INSTANCE_ID, &instance, COL_BUFFER, &buffer, -1); g_debug(" Get iter %p %p", buffer_current, buffer); if (ui_tree_view_last_event) { g_debug("last_event %p %d %d", ui_tree_view_last_event, ui_tree_view_last_event->type, ui_tree_view_last_event->button); if (ui_tree_view_last_event->type == GDK_BUTTON_PRESS) { /* Callback is due to a button click */ if (ui_tree_view_last_event->button == 1) { /* It was a left mouse click */ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON(ui_main_data.signals_go_to_last_button), FALSE); } if (ui_tree_view_last_event->button == 3) { /* It was a right mouse click */ int item; /* Clear event */ ui_tree_view_last_event = NULL; /* Create filter menus to refers its items in the pop-up menu */ ui_create_filter_menus (); g_info("Message selected right click %d %d %d %d", message_id, origin_task_id, destination_task_id, instance); /* Message Id menu */ { /* Invalidate associated menu item to avoid issue with call back when updating the menu item check state */ ui_tree_view_menu_enable[MENU_MESSAGE].filter_item = NULL; item = ui_filters_search_id (&ui_filters.messages, message_id); /* Update the menu item check state based on message ID state */ gtk_check_menu_item_set_active ( GTK_CHECK_MENU_ITEM(ui_tree_view_menu_enable[MENU_MESSAGE].menu_enable), ui_filters.messages.items[item].enabled); /* Set menu item label */ sprintf (label, "Message: %s", message_id_to_string (message_id)); gtk_menu_item_set_label (GTK_MENU_ITEM(ui_tree_view_menu_enable[MENU_MESSAGE].menu_enable), label); /* Save menu item associated to this row */ ui_tree_view_menu_enable[MENU_MESSAGE].filter_item = &ui_filters.messages.items[item]; } /* Origin task id */ { /* Invalidate associated menu item to avoid issue with call back when updating the menu item check state */ ui_tree_view_menu_enable[MENU_FROM_TASK].filter_item = NULL; item = ui_filters_search_id (&ui_filters.origin_tasks, origin_task_id); /* Update the menu item check state based on message ID state */ gtk_check_menu_item_set_active ( GTK_CHECK_MENU_ITEM(ui_tree_view_menu_enable[MENU_FROM_TASK].menu_enable), ui_filters.origin_tasks.items[item].enabled); /* Set menu item label */ sprintf (label, "From: %s", task_id_to_string (origin_task_id, origin_task_id_type)); gtk_menu_item_set_label ( GTK_MENU_ITEM(ui_tree_view_menu_enable[MENU_FROM_TASK].menu_enable), label); /* Save menu item associated to this row */ ui_tree_view_menu_enable[MENU_FROM_TASK].filter_item = &ui_filters.origin_tasks.items[item]; } /* Destination task id */ { /* Invalidate associated menu item to avoid issue with call back when updating the menu item check state */ ui_tree_view_menu_enable[MENU_TO_TASK].filter_item = NULL; item = ui_filters_search_id (&ui_filters.destination_tasks, destination_task_id); /* Update the menu item check state based on message ID state */ gtk_check_menu_item_set_active ( GTK_CHECK_MENU_ITEM(ui_tree_view_menu_enable[MENU_TO_TASK].menu_enable), ui_filters.destination_tasks.items[item].enabled); /* Set menu item label */ sprintf (label, "To: %s", task_id_to_string (destination_task_id, destination_task_id_type)); gtk_menu_item_set_label (GTK_MENU_ITEM(ui_tree_view_menu_enable[MENU_TO_TASK].menu_enable), label); /* Save menu item associated to this row */ ui_tree_view_menu_enable[MENU_TO_TASK].filter_item = &ui_filters.destination_tasks.items[item]; } /* Instance */ { /* Invalidate associated menu item to avoid issue with call back when updating the menu item check state */ ui_tree_view_menu_enable[MENU_INSTANCE].filter_item = NULL; item = ui_filters_search_id (&ui_filters.instances, instance); /* Update the menu item check state based on message ID state */ gtk_check_menu_item_set_active ( GTK_CHECK_MENU_ITEM(ui_tree_view_menu_enable[MENU_INSTANCE].menu_enable), ui_filters.instances.items[item].enabled); /* Set menu item label */ sprintf (label, "Instance: %s", instance_name); gtk_menu_item_set_label (GTK_MENU_ITEM(ui_tree_view_menu_enable[MENU_INSTANCE].menu_enable), label); /* Save menu item associated to this row */ ui_tree_view_menu_enable[MENU_INSTANCE].filter_item = &ui_filters.instances.items[item]; } gtk_menu_popup (GTK_MENU (ui_tree_view_menu), NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time ()); } } /* Clear event */ ui_tree_view_last_event = NULL; } if (buffer_current != buffer) { buffer_current = buffer; /* Clear the view */ CHECK_FCT_DO(ui_signal_dissect_clear_view(text_view), return FALSE); if (ui_main_data.display_message_header) { CHECK_FCT_DO(dissect_signal_header((buffer_t*)buffer, ui_signal_set_text, text_view), return FALSE); }
static void wl_httper_menu_init(WlHttperMenu * menu) { GtkWidget *properties = gtk_image_menu_item_new_from_stock(GTK_STOCK_PROPERTIES, NULL); gtk_menu_item_set_label(GTK_MENU_ITEM(properties), "Properties"); gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM (properties), TRUE); gtk_menu_shell_append(GTK_MENU_SHELL(menu), properties); GtkWidget *openDir = gtk_image_menu_item_new_from_stock(GTK_STOCK_OPEN, NULL); gtk_menu_item_set_label(GTK_MENU_ITEM(openDir), "Open Folder"); gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(openDir), TRUE); gtk_menu_shell_append(GTK_MENU_SHELL(menu), openDir); gtk_menu_shell_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); GtkWidget *startAction = gtk_image_menu_item_new_from_stock(GTK_STOCK_MEDIA_PLAY, NULL); gtk_menu_item_set_label(GTK_MENU_ITEM(startAction), "Start"); gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM (startAction), TRUE); gtk_menu_shell_append(GTK_MENU_SHELL(menu), startAction); GtkWidget *pauseAction = gtk_image_menu_item_new_from_stock(GTK_STOCK_MEDIA_PAUSE, NULL); gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM (pauseAction), TRUE); gtk_menu_shell_append(GTK_MENU_SHELL(menu), pauseAction); GtkWidget *abortAction = gtk_image_menu_item_new_from_stock(GTK_STOCK_MEDIA_STOP, NULL); gtk_menu_item_set_label(GTK_MENU_ITEM(abortAction), "Abort"); gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM (abortAction), TRUE); gtk_menu_shell_append(GTK_MENU_SHELL(menu), abortAction); gtk_menu_shell_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); GtkWidget *redlAction = gtk_menu_item_new_with_label("Re-Download"); gtk_menu_shell_append(GTK_MENU_SHELL(menu), redlAction); gtk_menu_shell_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); GtkWidget *copyURL = gtk_image_menu_item_new_from_stock(GTK_STOCK_COPY, NULL); gtk_menu_item_set_label(GTK_MENU_ITEM(copyURL), "Copy Download URL to Clipboard"); gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM (copyURL), TRUE); gtk_menu_shell_append(GTK_MENU_SHELL(menu), copyURL); gtk_widget_show_all(GTK_WIDGET(menu)); menu->httper = NULL; menu->properties = properties; menu->openDir = openDir; menu->copyURL = copyURL; menu->startAction = startAction; menu->pauseAction = pauseAction; menu->abortAction = abortAction; menu->redlAction = redlAction; menu->propertiesDialog = NULL; }
static void qq_tray_init(QQTray *tray) { gtk_status_icon_set_tooltip_markup(GTK_STATUS_ICON(tray), "<b>GtkQQ</b>"); QQTrayPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE(tray, qq_tray_get_type() , QQTrayPriv); priv -> blinking_queue = g_queue_new(); priv -> tmp_queue = g_queue_new(); priv -> popupmenu = gtk_menu_new(); GtkWidget *menuitem; menuitem = gtk_check_menu_item_new_with_label("Mute"); gtk_menu_shell_append(GTK_MENU_SHELL(priv -> popupmenu), menuitem); menuitem = gtk_separator_menu_item_new(); gtk_menu_shell_append(GTK_MENU_SHELL(priv -> popupmenu), menuitem); GtkWidget *img; GdkPixbuf *pb; #define STATUS_ITEM(x,y) \ menuitem = gtk_image_menu_item_new();\ gtk_menu_shell_append(GTK_MENU_SHELL(priv -> popupmenu), menuitem);\ pb = gdk_pixbuf_new_from_file_at_size(IMGDIR"/status/"x".png"\ , 12, 12, NULL);\ img = gtk_image_new_from_pixbuf(pb);\ g_object_unref(pb);\ gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), img);\ gtk_menu_item_set_label(GTK_MENU_ITEM(menuitem), y);\ g_signal_connect(G_OBJECT(menuitem), "activate"\ , G_CALLBACK(qq_tray_status_menu_item_activate), x); STATUS_ITEM("online", "Online"); STATUS_ITEM("hidden", "Hidden"); STATUS_ITEM("away", "Away"); STATUS_ITEM("busy", "Busy"); STATUS_ITEM("callme", "Call Me"); STATUS_ITEM("silent", "Silent"); #undef STATUS_ITEM menuitem = gtk_separator_menu_item_new(); gtk_menu_shell_append(GTK_MENU_SHELL(priv -> popupmenu), menuitem); menuitem = gtk_menu_item_new_with_label("Personal Setting"); g_signal_connect(G_OBJECT(menuitem), "activate" , G_CALLBACK(qq_tray_personal_setting_menu_item_activate) , NULL); gtk_menu_shell_append(GTK_MENU_SHELL(priv -> popupmenu), menuitem); menuitem = gtk_menu_item_new_with_label("System Setting"); g_signal_connect(G_OBJECT(menuitem), "activate" , G_CALLBACK(qq_tray_system_setting_menu_item_activate) , NULL); gtk_menu_shell_append(GTK_MENU_SHELL(priv -> popupmenu), menuitem); menuitem = gtk_separator_menu_item_new(); gtk_menu_shell_append(GTK_MENU_SHELL(priv -> popupmenu), menuitem); menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_ABOUT, NULL); g_signal_connect(G_OBJECT(menuitem), "activate" , G_CALLBACK(qq_tray_about_menu_item_activate) , NULL); gtk_menu_shell_append(GTK_MENU_SHELL(priv -> popupmenu), menuitem); gtk_menu_item_set_label(GTK_MENU_ITEM(menuitem), "About GtkQQ"); menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, NULL); g_signal_connect(G_OBJECT(menuitem), "activate" , G_CALLBACK(qq_tray_quit_menu_item_activate) , NULL); gtk_menu_shell_append(GTK_MENU_SHELL(priv -> popupmenu), menuitem); gtk_menu_item_set_label(GTK_MENU_ITEM(menuitem), "Quit"); gtk_widget_show_all(priv -> popupmenu); g_signal_connect(G_OBJECT(tray), "popup-menu" , G_CALLBACK(qq_tray_popup_menu), tray); g_signal_connect(G_OBJECT(tray), "button-press-event" , G_CALLBACK(qq_tray_button_press), tray); g_signal_connect(G_OBJECT(tray), "query-tooltip" , G_CALLBACK(qq_tray_on_show_tooltip), tray); }
static void add_screen(xcb_randr_get_screen_info_reply_t *reply) { const gchar *title = "Display"; GtkWidget *item = gtk_menu_item_new_with_label(title); GtkMenuShell *menu = GTK_MENU_SHELL(app_menu); struct screen_info *info = g_malloc(sizeof *info); xcb_randr_rotation_t rotation = normalize_rotation(reply->rotation); xcb_randr_rotation_t rotations = reply->rotations; info->label_menu_item = item; info->rotation_menu_group = NULL; info->rotation = rotation; info->config_timestamp = reply->config_timestamp; info->root = reply->root; info->sizeID = reply->sizeID; info->rate = reply->rate; screens_info = g_slist_append(screens_info, info); gtk_widget_set_sensitive(item, FALSE); gtk_menu_shell_append(menu, item); #define R(rot, title) \ if (rotations & XCB_RANDR_ROTATION_##rot) \ add_screen_rotation(info, XCB_RANDR_ROTATION_##rot, title, \ XCB_RANDR_ROTATION_##rot & rotation) R(ROTATE_0, "Landscape"); R(ROTATE_90, "Portrait"); R(ROTATE_180, "Landscape Flipped"); R(ROTATE_270, "Portrait Flipped"); if (rotations & xcb_rotations_mask && rotations & xcb_reflections_mask) gtk_menu_shell_append(menu, gtk_separator_menu_item_new()); R(REFLECT_X, "Reflected X"); R(REFLECT_Y, "Reflected Y"); #undef R gtk_menu_shell_append(menu, gtk_separator_menu_item_new()); gtk_widget_show_all(app_menu); /* Get screen resources */ xcb_randr_get_screen_resources_current_cookie_t resources_cookie; xcb_randr_get_screen_resources_current_reply_t *resources_reply; xcb_generic_error_t *err = NULL; resources_cookie = xcb_randr_get_screen_resources_current(conn, info->root); resources_reply = xcb_randr_get_screen_resources_current_reply(conn, resources_cookie, &err); if (err) { g_warning("Get Screen Resources returned error %u\n", err->error_code); return; } /* Get screen outputs */ xcb_randr_output_t *outputs; guint i; gchar *output_name; outputs = xcb_randr_get_screen_resources_current_outputs(resources_reply); for (i = 0; i < resources_reply->num_outputs; i++) { xcb_randr_get_output_info_reply_t *output_info_reply; xcb_randr_get_output_info_cookie_t output_info_cookie = xcb_randr_get_output_info_unchecked(conn, outputs[i], resources_reply->config_timestamp); output_info_reply = xcb_randr_get_output_info_reply(conn, output_info_cookie, NULL); /* Show only if connected */ switch (output_info_reply->connection) { case XCB_RANDR_CONNECTION_DISCONNECTED: case XCB_RANDR_CONNECTION_UNKNOWN: continue; case XCB_RANDR_CONNECTION_CONNECTED: break; } output_name = get_output_name(output_info_reply); /* Put output names on the menu */ gtk_menu_item_set_label(GTK_MENU_ITEM(item), output_name); g_free(output_name); /* TODO: concatenate multiple names or pick them intelligently */ } }
static void update_sensor_menu_item_label(IsIndicator *self, IsSensor *sensor, GtkMenuItem *menu_item) { gchar *text; text = g_strdup_printf("%s %2.*f%s", is_sensor_get_label(sensor), is_sensor_get_digits(sensor), is_sensor_get_value(sensor), is_sensor_get_units(sensor)); gtk_menu_item_set_label(menu_item, text); g_free(text); text = NULL; #if HAVE_APPINDICATOR if (sensor == self->priv->primary) { IsIndicatorPrivate *priv = self->priv; gboolean connected; g_object_get(self, "connected", &connected, NULL); /* using fallback so just set icon */ if (!connected) { app_indicator_set_icon_full(APP_INDICATOR(self), PACKAGE, is_sensor_get_label(sensor)); return; } if (priv->display_flags & IS_INDICATOR_DISPLAY_VALUE) { text = g_strdup_printf("%2.*f%s", is_sensor_get_digits(sensor), is_sensor_get_value(sensor), is_sensor_get_units(sensor)); } if (priv->display_flags & IS_INDICATOR_DISPLAY_LABEL) { /* join label to existing text - if text is NULL this will just show label */ text = g_strjoin(" ", is_sensor_get_label(sensor), text, NULL); } if (priv->display_flags & IS_INDICATOR_DISPLAY_ICON) { app_indicator_set_icon_full(APP_INDICATOR(self), is_sensor_get_icon_path(sensor), is_sensor_get_label(sensor)); } else { /* set to a 1x1 transparent icon for no icon */ app_indicator_set_icon_full(APP_INDICATOR(self), "indicator-sensors-no-icon", is_sensor_get_label(sensor)); } app_indicator_set_label(APP_INDICATOR(self), text, text); g_free(text); app_indicator_set_status(APP_INDICATOR(self), is_sensor_get_alarmed(sensor) ? APP_INDICATOR_STATUS_ATTENTION : APP_INDICATOR_STATUS_ACTIVE); } #else gtk_status_icon_set_from_icon_name(GTK_STATUS_ICON(self), PACKAGE); #endif }