static int heartbeat(gpointer data) { refresh_state_info(); /* check watchdog */ if (ctrl_shm->watchdog < 10) { ctrl_shm->watchdog++; } else { handle_watchdog_timeout(); } if (ctrl_usr->pending_restart && ctrl_shm->state == IDLE) { ctrl_usr->pending_restart = 0; ctrl_usr->run_mode = ctrl_usr->old_run_mode; if(ctrl_usr->run_mode != STOP) { start_capture(); } } if (ctrl_usr->display_refresh_timer > 0) { /* decrement timer, did it time out? */ if (--ctrl_usr->display_refresh_timer == 0) { /* yes, refresh the display */ refresh_display(); } } if (ctrl_shm->state == DONE) { if(!gtk_window_is_active(GTK_WINDOW(ctrl_usr->main_win))) gtk_window_set_urgency_hint(GTK_WINDOW(ctrl_usr->main_win), TRUE); capture_complete(); } else if (ctrl_usr->run_mode == ROLL) capture_cont(); return 1; }
static gboolean gtk_frame_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxTopLevelWindowGTK *win ) { g_activeFrame = win; // MR: wxRequestUserAttention related block switch( win->m_urgency_hint ) { default: g_source_remove( win->m_urgency_hint ); // no break, fallthrough to remove hint too case -1: gtk_window_set_urgency_hint(GTK_WINDOW(widget), false); win->m_urgency_hint = -2; break; case -2: break; } wxActivateEvent event(wxEVT_ACTIVATE, true, g_activeFrame->GetId()); event.SetEventObject(g_activeFrame); g_activeFrame->HandleWindowEvent(event); return FALSE; }
void wxTopLevelWindowGTK::RequestUserAttention(int flags) { bool new_hint_value = false; // FIXME: This is a workaround to focus handling problem // If RequestUserAttention is called for example right after a wxSleep, OnInternalIdle hasn't // yet been processed, and the internal focus system is not up to date yet. // wxYieldIfNeeded ensures the processing of it, but can have unwanted side effects - MR ::wxYieldIfNeeded(); if(m_urgency_hint >= 0) g_source_remove(m_urgency_hint); m_urgency_hint = -2; if( GTK_WIDGET_REALIZED(m_widget) && !IsActive() ) { new_hint_value = true; if (flags & wxUSER_ATTENTION_INFO) { m_urgency_hint = g_timeout_add(5000, (GSourceFunc)gtk_frame_urgency_timer_callback, this); } else { m_urgency_hint = -1; } } #if GTK_CHECK_VERSION(2,7,0) if(!gtk_check_version(2,7,0)) gtk_window_set_urgency_hint(GTK_WINDOW( m_widget ), new_hint_value); else #endif wxgtk_window_set_urgency_hint(GTK_WINDOW( m_widget ), new_hint_value); }
JNIEXPORT void JNICALL Java_org_gnome_gtk_GtkWindow_gtk_1window_1set_1urgency_1hint ( JNIEnv* env, jclass cls, jlong _self, jboolean _setting ) { GtkWindow* self; gboolean setting; // convert parameter self self = (GtkWindow*) _self; // convert parameter setting setting = (gboolean) _setting; // call function gtk_window_set_urgency_hint(self, setting); // cleanup parameter self // cleanup parameter setting }
void setDialogProperties(GtkWidget *dialog, GtkWidget *window) { gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(window)); gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); gtk_window_set_urgency_hint(GTK_WINDOW(dialog), TRUE); }
static gboolean gtk_frame_urgency_timer_callback( wxTopLevelWindowGTK *win ) { gtk_window_set_urgency_hint(GTK_WINDOW(win->m_widget), false); win->m_urgency_hint = -2; return FALSE; }
static void wxgtk_window_set_urgency_hint (GtkWindow *win, gboolean setting) { #if GTK_CHECK_VERSION(2,7,0) if (gtk_check_version(2,7,0) == NULL) gtk_window_set_urgency_hint(win, setting); else #endif { #ifdef GDK_WINDOWING_X11 GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(win)); wxCHECK_RET(window, "wxgtk_window_set_urgency_hint: GdkWindow not realized"); Display* dpy = GDK_WINDOW_XDISPLAY(window); Window xid = GDK_WINDOW_XID(window); XWMHints* wm_hints = XGetWMHints(dpy, xid); if (!wm_hints) wm_hints = XAllocWMHints(); if (setting) wm_hints->flags |= XUrgencyHint; else wm_hints->flags &= ~XUrgencyHint; XSetWMHints(dpy, xid, wm_hints); XFree(wm_hints); #endif // GDK_WINDOWING_X11 } }
void wxTopLevelWindowGTK::RequestUserAttention(int flags) { bool new_hint_value = false; // FIXME: This is a workaround to focus handling problem // If RequestUserAttention is called for example right after a wxSleep, OnInternalIdle // hasn't yet been processed, and the internal focus system is not up to date yet. // YieldFor(wxEVT_CATEGORY_UI) ensures the processing of it (hopefully it // won't have side effects) - MR wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI); if(m_urgency_hint >= 0) g_source_remove(m_urgency_hint); m_urgency_hint = -2; if( gtk_widget_get_realized(m_widget) && !IsActive() ) { new_hint_value = true; if (flags & wxUSER_ATTENTION_INFO) { m_urgency_hint = g_timeout_add(5000, (GSourceFunc)gtk_frame_urgency_timer_callback, this); } else { m_urgency_hint = -1; } } gtk_window_set_urgency_hint(GTK_WINDOW(m_widget), new_hint_value); }
static gboolean focus_in_event (GtkWidget *widget, GdkEventFocus *event) { if (gtk_window_get_urgency_hint (GTK_WINDOW (widget))) gtk_window_set_urgency_hint (GTK_WINDOW (widget), false); return GTK_WIDGET_CLASS (ekiga_ext_window_parent_class)->focus_in_event (widget, event); }
static gboolean gtk_frame_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxTopLevelWindowGTK *win ) { // don't need to install idle handler, its done from "event" signal switch ( g_sendActivateEvent ) { case -1: // we've got focus from outside, synthetize wxActivateEvent g_sendActivateEvent = 1; break; case 0: // another our window just lost focus, it was already ours before // - don't send any wxActivateEvent g_sendActivateEvent = -1; break; } g_activeFrame = win; g_lastActiveFrame = g_activeFrame; // wxPrintf( wxT("active: %s\n"), win->GetTitle().c_str() ); // MR: wxRequestUserAttention related block switch( win->m_urgency_hint ) { default: g_source_remove( win->m_urgency_hint ); // no break, fallthrough to remove hint too case -1: #if GTK_CHECK_VERSION(2,7,0) if(!gtk_check_version(2,7,0)) gtk_window_set_urgency_hint(GTK_WINDOW( widget ), FALSE); else #endif { wxgtk_window_set_urgency_hint(GTK_WINDOW( widget ), FALSE); } win->m_urgency_hint = -2; break; case -2: break; } wxLogTrace(wxT("activate"), wxT("Activating frame %p (from focus_in)"), g_activeFrame); wxActivateEvent event(wxEVT_ACTIVATE, true, g_activeFrame->GetId()); event.SetEventObject(g_activeFrame); g_activeFrame->GetEventHandler()->ProcessEvent(event); return FALSE; }
static void chat_window_set_urgency_hint (EmpathyChatWindow *window, gboolean urgent) { EmpathyChatWindowPriv *priv; priv = GET_PRIV (window); DEBUG ("Turning %s urgency hint", urgent ? "on" : "off"); gtk_window_set_urgency_hint (GTK_WINDOW (priv->dialog), urgent); }
static void term_beeped (VteTerminal *vtterm, gpointer userdata) { /* * Only set the _URGENT hint when the window is not focused. If the * window is focused, the user is likely to notice what is happening * without the need to call for attention. */ if (!gtk_window_has_toplevel_focus (GTK_WINDOW (userdata))) gtk_window_set_urgency_hint (GTK_WINDOW (userdata), TRUE); }
static gboolean gtk_frame_urgency_timer_callback( wxTopLevelWindowGTK *win ) { #if GTK_CHECK_VERSION(2,7,0) if(!gtk_check_version(2,7,0)) gtk_window_set_urgency_hint(GTK_WINDOW( win->m_widget ), FALSE); else #endif wxgtk_window_set_urgency_hint(GTK_WINDOW( win->m_widget ), FALSE); win->m_urgency_hint = -2; return FALSE; }
static void auth_dialog (DBusGProxy *adapter, DBusGProxy *device, const char *name, const char *long_name, const char *uuid, DBusGMethodInvocation *context) { GtkBuilder *xml; GtkWidget *dialog; GtkWidget *button; char *str; input_data *input; input = g_new0 (input_data, 1); input->path = g_strdup (dbus_g_proxy_get_path (adapter)); input->uuid = g_strdup (uuid); input->device = g_object_ref (device); input->context = context; xml = gtk_builder_new (); if (gtk_builder_add_from_file (xml, "authorisation-dialogue.ui", NULL) == 0) gtk_builder_add_from_file (xml, PKGDATADIR "/authorisation-dialogue.ui", NULL); dialog = GTK_WIDGET (gtk_builder_get_object (xml, "dialog")); gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER); if (notification_supports_actions () != FALSE) gtk_window_set_keep_above (GTK_WINDOW (dialog), TRUE); else gtk_window_set_focus_on_map (GTK_WINDOW (dialog), FALSE); gtk_window_set_urgency_hint (GTK_WINDOW (dialog), TRUE); input->dialog = dialog; /* translators: Whether to grant access to a particular service */ str = g_strdup_printf (_("Grant access to '%s'"), uuid); g_object_set (G_OBJECT (dialog), "text", str, NULL); g_free (str); gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), _("Device %s wants access to the service '%s'."), long_name, uuid); button = GTK_WIDGET (gtk_builder_get_object (xml, "always_button")); input->button = button; input_list = g_list_append (input_list, input); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (auth_callback), input); enable_blinking (); }
gboolean termit_on_focus(GtkWidget *widget, GtkDirectionType arg1, gpointer user_data) { struct TermitTab* pTab = (struct TermitTab*)user_data; if (!pTab) { ERROR("pTab is NULL"); return FALSE; } if (gtk_window_get_urgency_hint(GTK_WINDOW(termit.main_window))) { gtk_window_set_urgency_hint(GTK_WINDOW(termit.main_window), FALSE); gtk_label_set_markup(GTK_LABEL(pTab->tab_name), gtk_label_get_text(GTK_LABEL(pTab->tab_name))); gtk_label_set_use_markup(GTK_LABEL(pTab->tab_name), FALSE); } return FALSE; }
static void confirm_dialog (DBusGProxy *adapter, DBusGProxy *device, const char *name, const char *long_name, const char *value, DBusGMethodInvocation *context) { GtkWidget *dialog; GtkBuilder *xml; char *str; input_data *input; input = g_new0 (input_data, 1); input->path = g_strdup (dbus_g_proxy_get_path(adapter)); input->device = g_object_ref (device); input->context = context; xml = gtk_builder_new (); if (gtk_builder_add_from_file (xml, "confirm-dialogue.ui", NULL) == 0) gtk_builder_add_from_file (xml, PKGDATADIR "/confirm-dialogue.ui", NULL); dialog = GTK_WIDGET (gtk_builder_get_object (xml, "dialog")); gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER); if (notification_supports_actions () != FALSE) gtk_window_set_keep_above (GTK_WINDOW (dialog), TRUE); else gtk_window_set_focus_on_map (GTK_WINDOW (dialog), FALSE); gtk_window_set_urgency_hint (GTK_WINDOW (dialog), TRUE); input->dialog = dialog; str = g_strdup_printf (_("Device '%s' wants to pair with this computer"), name); g_object_set (G_OBJECT (dialog), "text", str, NULL); g_free (str); str = g_strdup_printf ("<b>%s</b>", value); gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog), _("Please confirm whether the PIN '%s' matches the one on device %s."), str, long_name); g_free (str); input_list = g_list_append (input_list, input); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (confirm_callback), input); enable_blinking (); }
gboolean deja_dup_user_focused (GtkWidget* win, GdkEventFocus* e) { gboolean result = FALSE; GtkWidget* _tmp0_; GtkWidget* _tmp1_; guint _tmp2_ = 0U; g_return_val_if_fail (win != NULL, FALSE); g_return_val_if_fail (e != NULL, FALSE); _tmp0_ = win; gtk_window_set_urgency_hint (GTK_WINDOW (_tmp0_), FALSE); _tmp1_ = win; g_signal_parse_name ("focus-in-event", GTK_TYPE_WIDGET, &_tmp2_, NULL, FALSE); g_signal_handlers_disconnect_matched (_tmp1_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp2_, 0, NULL, (GCallback) _deja_dup_user_focused_gtk_widget_focus_in_event, NULL); result = FALSE; return result; }
static void window_has_toplevel_focus_notified (GObject *object, GParamSpec *pspec, gpointer userdata) { if (gtk_window_has_toplevel_focus (GTK_WINDOW (object))) { vte_terminal_set_color_cursor (VTE_TERMINAL (userdata), &cursor_active); /* Clear the _URGENT hint when the window gets activated. */ gtk_window_set_urgency_hint (GTK_WINDOW (object), FALSE); } else { vte_terminal_set_color_cursor (VTE_TERMINAL (userdata), &cursor_inactive); } }
void termit_on_beep(VteTerminal *vte, gpointer user_data) { struct TermitTab* pTab = (struct TermitTab*)user_data; if (!pTab) { ERROR("pTab is NULL"); return; } if (!gtk_window_has_toplevel_focus(GTK_WINDOW(termit.main_window))) { if (configs.urgency_on_bell) { gtk_window_set_urgency_hint(GTK_WINDOW(termit.main_window), TRUE); gchar* marked_title = g_strdup_printf("<b>%s</b>", gtk_label_get_text(GTK_LABEL(pTab->tab_name))); gtk_label_set_markup(GTK_LABEL(pTab->tab_name), marked_title); g_free(marked_title); } } }
static gboolean OnFocusInFS(GtkWidget *widget, GdkEvent *event, gpointer user_data) { Application.Active = true; if (Application.FullScreenMode()) { fullscreen_needs_restore = true; gdk_threads_add_idle(fullscreen_restore, NULL); } C4Window *window = (C4Window*) user_data; if (window->mouse_was_grabbed) gdk_threads_add_timeout(50, grab_mouse_fn, widget); // Reset urgency hint (does nothing if unset) assert(widget == window->window && "OnFocusInFS callback used for something other than the main window."); gtk_window_set_urgency_hint(GTK_WINDOW(window->window), false); return false; }
static gboolean ekiga_dbus_component_show (EkigaDBusComponent *self, G_GNUC_UNUSED GError **error) { PTRACE (1, "DBus\tShow"); boost::shared_ptr<GtkFrontend> gtk_frontend = self->priv->gtk_frontend.lock (); g_return_val_if_fail (gtk_frontend, FALSE); const GtkWidget *window = gtk_frontend->get_main_window (); if (gtk_widget_get_visible (GTK_WIDGET (window))) gtk_window_set_urgency_hint (GTK_WINDOW (window), TRUE); else gtk_window_present (GTK_WINDOW (window)); return TRUE; }
void fe_print_text (struct session *sess, char *text, time_t stamp) { if (text == NULL) { g_warning ("NULL passed to fe_print_text. Perhaps a misbehaving plugin?\n"); return; } conversation_panel_print (CONVERSATION_PANEL (gui.conversation_panel), sess, text, prefs.indent_nicks, stamp); sess->new_data = TRUE; navigation_model_set_hilight (gui.tree_model, sess); if (sess->nick_said) { if (!gtk_window_is_active (GTK_WINDOW (gui.main_window))) { gtk_window_set_urgency_hint (GTK_WINDOW (gui.main_window), TRUE); } } }
void notification_update_urgency_hint(void) { MainWindow *mainwin; mainwin = mainwindow_get_mainwindow(); if(mainwin) { NotificationMsgCount count; gboolean active; active = FALSE; if(notify_config.urgency_hint_new || notify_config.urgency_hint_unread) { notification_core_get_msg_count(NULL, &count); if(notify_config.urgency_hint_new) active = (active || (count.new_msgs > 0)); if(notify_config.urgency_hint_unread) active = (active || (count.unread_msgs > 0)); } gtk_window_set_urgency_hint(GTK_WINDOW(mainwin->window), active); } }
static int32_t dt_film_import1_run(dt_job_t *job) { dt_film_import1_t *params = dt_control_job_get_params(job); dt_film_import1(job, params->film); dt_pthread_mutex_lock(¶ms->film->images_mutex); params->film->ref--; dt_pthread_mutex_unlock(¶ms->film->images_mutex); if(params->film->ref <= 0) { if(dt_film_is_empty(params->film->id)) { dt_film_remove(params->film->id); } } // notify the user via the window manager if(darktable.gui) gtk_window_set_urgency_hint(GTK_WINDOW(dt_ui_main_window(darktable.gui->ui)), TRUE); return 0; }
void C4Window::FlashWindow() { gtk_window_set_urgency_hint(GTK_WINDOW(window), true); }
void main_gui(int argc, char **argv) { /* inits */ gdk_threads_init(); gdk_threads_enter(); gtk_init (&argc, &argv); pthread_mutex_init(&mutex_guichange, NULL); /* window */ gres.window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_container_set_border_width(GTK_CONTAINER(gres.window), 0); gtk_window_set_urgency_hint (GTK_WINDOW(gres.window), TRUE); gtk_window_set_title (GTK_WINDOW (gres.window), _PROJECTNAME); gtk_window_set_default_size(GTK_WINDOW(gres.window), 800, 600); gtk_window_set_position(GTK_WINDOW(gres.window), GTK_WIN_POS_CENTER); gtk_window_set_resizable(GTK_WINDOW(gres.window), TRUE); /* setting window icon */ gtk_window_set_icon(GTK_WINDOW(gres.window), create_pixbuf(GUI_ICON)); gtk_widget_show(gres.window); g_signal_connect(G_OBJECT(gres.window), "delete_event", G_CALLBACK(on_destroy), NULL); g_signal_connect(G_OBJECT(gres.window), "destroy", G_CALLBACK(on_destroy), NULL); /* vbox principale */ gres.vbox_main = gtk_box_new (GTK_ORIENTATION_VERTICAL, 1); gtk_container_add(GTK_CONTAINER(gres.window), gres.vbox_main); gtk_container_set_border_width(GTK_CONTAINER(gres.vbox_main),0); /* accellgroup */ gres.accel_group = gtk_accel_group_new(); gtk_window_add_accel_group(GTK_WINDOW(gres.window), gres.accel_group); /* menubar */ gres.menubar = gtk_menu_bar_new(); gres.filemenu = gtk_menu_new(); gres.helpmenu = gtk_menu_new(); gres.file = gtk_menu_item_new_with_label("File"); //gres.connect = gtk_image_menu_item_new_from_stock(GTK_STOCK_NEW, NULL); gres.open = gtk_image_menu_item_new_from_stock(GTK_STOCK_OPEN, NULL); gres.font = gtk_image_menu_item_new_from_stock(GTK_STOCK_SELECT_FONT, NULL); gres.sep = gtk_separator_menu_item_new(); gres.quit = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, gres.accel_group); gres.help = gtk_image_menu_item_new_from_stock(GTK_STOCK_HELP, NULL); gres.about = gtk_image_menu_item_new_from_stock(GTK_STOCK_ABOUT, NULL); gtk_menu_item_set_submenu(GTK_MENU_ITEM(gres.file), gres.filemenu); //gtk_menu_shell_append(GTK_MENU_SHELL(gres.filemenu), gres.connect); gtk_menu_shell_append(GTK_MENU_SHELL(gres.filemenu), gres.font); gtk_menu_shell_append(GTK_MENU_SHELL(gres.filemenu), gres.sep); gtk_menu_shell_append(GTK_MENU_SHELL(gres.filemenu), gres.quit); gtk_menu_shell_append(GTK_MENU_SHELL(gres.menubar), gres.file); gtk_menu_item_set_submenu(GTK_MENU_ITEM(gres.help), gres.helpmenu); gtk_menu_shell_append(GTK_MENU_SHELL(gres.helpmenu), gres.about); gtk_menu_shell_append(GTK_MENU_SHELL(gres.menubar), gres.help); gtk_box_pack_start(GTK_BOX(gres.vbox_main), gres.menubar, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(gres.quit), "activate", G_CALLBACK(gtk_main_quit), NULL); g_signal_connect(G_OBJECT(gres.font), "activate", G_CALLBACK(select_font), G_OBJECT(gres.window)); g_signal_connect(G_OBJECT(gres.about), "activate", G_CALLBACK(show_about), NULL); /* toolbar */ gres.toolbar = gtk_toolbar_new(); gtk_toolbar_set_style(GTK_TOOLBAR(gres.toolbar), GTK_TOOLBAR_BOTH); gtk_container_set_border_width(GTK_CONTAINER(gres.toolbar), 2); gres.toolbar_connect = gtk_tool_button_new_from_stock(GTK_STOCK_NETWORK); if (!c_core->GetSession()->IsConnected()) gtk_tool_button_set_label(GTK_TOOL_BUTTON(gres.toolbar_connect), "Connect"); else gtk_tool_button_set_label(GTK_TOOL_BUTTON(gres.toolbar_connect), "Disconnect"); gtk_toolbar_insert(GTK_TOOLBAR(gres.toolbar), gres.toolbar_connect, -1); g_signal_connect(G_OBJECT(gres.toolbar_connect), "clicked", G_CALLBACK(toolbar_connect_click), NULL); //gres.toolbar_refresh = gtk_tool_button_new_from_stock(GTK_STOCK_REFRESH); //gtk_toolbar_insert(GTK_TOOLBAR(gres.toolbar), gres.toolbar_refresh, -1); //g_signal_connect(G_OBJECT(gres.toolbar_refresh), "clicked", G_CALLBACK(set_nick), G_OBJECT(gres.window)); gres.toolbar_reset = gtk_tool_button_new_from_stock(GTK_STOCK_CLEAR); gtk_toolbar_insert(GTK_TOOLBAR(gres.toolbar), gres.toolbar_reset, -1); g_signal_connect(G_OBJECT(gres.toolbar_reset), "clicked", G_CALLBACK(toolbar_reset_click), NULL); gres.toolbar_separator = gtk_separator_tool_item_new(); gtk_toolbar_insert(GTK_TOOLBAR(gres.toolbar), gres.toolbar_separator, -1); gres.toolbar_exit = gtk_tool_button_new_from_stock(GTK_STOCK_QUIT); gtk_toolbar_insert(GTK_TOOLBAR(gres.toolbar), gres.toolbar_exit, -1); g_signal_connect(G_OBJECT(gres.toolbar_exit), "clicked", G_CALLBACK(gtk_main_quit), NULL); gtk_box_pack_start(GTK_BOX(gres.vbox_main), gres.toolbar, FALSE, FALSE, 0); /* Paned */ gres.paned_main = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL); gtk_box_pack_start(GTK_BOX(gres.vbox_main), gres.paned_main, TRUE, TRUE, 0); gres.scrolledwindow_chat = gtk_scrolled_window_new (NULL, NULL); gtk_paned_pack1 (GTK_PANED(gres.paned_main), gres.scrolledwindow_chat, true, true); gtk_container_set_border_width (GTK_CONTAINER (gres.scrolledwindow_chat), 2); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (gres.scrolledwindow_chat), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gres.view_chat = gtk_text_view_new(); GdkRGBA color; gdk_rgba_parse (&color, CFG_GET_STRING("chat_bg").c_str()); gtk_widget_override_background_color(GTK_WIDGET(gres.view_chat), GTK_STATE_FLAG_NORMAL, &color); PangoFontDescription *font_desc = pango_font_description_from_string(CFG_GET_STRING("chat_font").c_str()); if (font_desc) gtk_widget_modify_font(gres.view_chat, font_desc); gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(gres.view_chat), GTK_WRAP_WORD_CHAR); gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (gres.view_chat), FALSE); gtk_text_view_set_left_margin (GTK_TEXT_VIEW (gres.view_chat), 1); gtk_text_view_set_right_margin (GTK_TEXT_VIEW (gres.view_chat), 1); gtk_text_view_set_editable(GTK_TEXT_VIEW(gres.view_chat), FALSE); gtk_container_add (GTK_CONTAINER (gres.scrolledwindow_chat), gres.view_chat); gres.tbuf_chat = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gres.view_chat)); gtk_text_buffer_create_tag(gres.tbuf_chat, "chat_bg", "background", CFG_GET_STRING("chat_bg").c_str() , NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "chat_sys_msg_fg", "foreground", CFG_GET_STRING("chat_sys_msg_fg").c_str() , NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "chat_msg_fg", "foreground", CFG_GET_STRING("chat_msg_fg").c_str() , NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "chat_join_fg", "foreground", CFG_GET_STRING("chat_join_fg").c_str() , NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "chat_leave_fg", "foreground", CFG_GET_STRING("chat_leave_fg").c_str() , NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "chat_whisp_fg", "foreground", CFG_GET_STRING("chat_whisp_fg").c_str() , NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "gap", "pixels_above_lines", 30, NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "lmarg", "left_margin", 5, NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "black_fg", "foreground", "#000000", NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "white_fg", "foreground", "#ffffff", NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "blue_fg", "foreground", "#3200ff", NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "magenta_fg", "foreground", "#ff32ff", NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "green_fg", "foreground", "#55ff00", NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "red_fg", "foreground", "#ff3200", NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "green_bg", "background", "#55ff00", NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "blue_bg", "background", "#3200ff", NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "red_bg", "background", "#ff3200", NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "yellow_bg", "background", "#f7f732", NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "magenta_bg", "background", "#ff32ff", NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "italic", "style", PANGO_STYLE_ITALIC, NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "bold", "weight", PANGO_WEIGHT_BOLD, NULL); gres.scrolledwindow_user_list = gtk_scrolled_window_new (NULL, NULL); gtk_paned_pack2 (GTK_PANED(gres.paned_main), gres.scrolledwindow_user_list, false, false); gtk_container_set_border_width (GTK_CONTAINER (gres.scrolledwindow_user_list), 2); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (gres.scrolledwindow_user_list), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_widget_show (gres.scrolledwindow_user_list); gres.model_user_list = gtk_list_store_new(COLUMNS, G_TYPE_STRING, G_TYPE_STRING); gres.view_user_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL(gres.model_user_list)); gres.selection_user_list = gtk_tree_view_get_selection(GTK_TREE_VIEW(gres.view_user_list)); gtk_tree_selection_set_mode(gres.selection_user_list, GTK_SELECTION_SINGLE); gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(gres.view_user_list), TRUE); gres.renderer_user_list = gtk_cell_renderer_text_new(); gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(gres.view_user_list), /* vista */ -1, /* posizione della colonna */ "Name", /* titolo della colonna */ gres.renderer_user_list, /* cella inserita nella colonna */ "text", /* attributo colonna */ COLUMN_STRING1, /* colonna inserita */ NULL); /* fine ;-) */ gres.renderer_user_list = gtk_cell_renderer_text_new(); gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(gres.view_user_list), -1, "Type", gres.renderer_user_list, "text", COLUMN_STRING2, NULL); gtk_widget_show (gres.view_user_list); g_object_unref(gres.model_user_list); gtk_container_add (GTK_CONTAINER (gres.scrolledwindow_user_list), gres.view_user_list); gtk_container_set_border_width (GTK_CONTAINER (gres.view_user_list), 0); gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (gres.view_user_list), TRUE); /* INPUTS */ gres.hbox_inputs = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_pack_start(GTK_BOX (gres.vbox_main), gres.hbox_inputs, FALSE, FALSE, 0); gres.label_nick = gtk_label_new((gchar *) CFG_GET_STRING("username").c_str()); gtk_misc_set_alignment(GTK_MISC(gres.label_nick), 0.0, 0.5); gtk_box_pack_start(GTK_BOX (gres.hbox_inputs), gres.label_nick, FALSE, FALSE, 2 ); gres.entry_command = gtk_entry_new(); gtk_box_pack_start(GTK_BOX (gres.hbox_inputs), gres.entry_command, TRUE, TRUE, 5); gres.button_send = gtk_button_new_with_label("Send"); gtk_widget_set_size_request (GTK_WIDGET (gres.button_send), 70, 30); gtk_box_pack_start(GTK_BOX (gres.hbox_inputs), gres.button_send, FALSE, FALSE, 0); gres.text_entry = gres.entry_command; g_signal_connect(G_OBJECT(gres.entry_command), "activate", G_CALLBACK(button_send_click), NULL); g_signal_connect(G_OBJECT(gres.button_send), "clicked", G_CALLBACK(button_send_click), NULL); /* status_bar */ gres.status_bar = gtk_statusbar_new(); gtk_box_pack_start(GTK_BOX (gres.vbox_main), gres.status_bar, FALSE, FALSE, 0); /* end_widgets */ gtk_widget_show_all(gres.window); /* default focus on command entry */ gtk_widget_grab_focus (GTK_WIDGET(gres.text_entry)); INFO ("debug", "GUI: starting GUI thread\n"); pthread_t tid; StartThread(GuiThread, (void*)&gres, tid); INFO ("debug", "GUI: starting GTK+3\n"); gtk_main(); gdk_threads_leave(); pthread_mutex_destroy(&mutex_guichange); return; }
static void gsd_ldsm_dialog_init (GsdLdsmDialog *dialog) { GtkWidget *main_vbox, *text_vbox, *hbox; GtkWidget *image; dialog->priv = GSD_LDSM_DIALOG_GET_PRIVATE (dialog); main_vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); /* Set up all the window stuff here */ gtk_window_set_title (GTK_WINDOW (dialog), _("Low Disk Space")); gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_DIALOG_WARNING); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER); gtk_window_set_urgency_hint (GTK_WINDOW (dialog), TRUE); gtk_window_set_focus_on_map (GTK_WINDOW (dialog), FALSE); gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); /* Create the image */ image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG); gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0); /* Create the labels */ dialog->priv->primary_label = gtk_label_new (NULL); gtk_label_set_line_wrap (GTK_LABEL (dialog->priv->primary_label), TRUE); gtk_label_set_single_line_mode (GTK_LABEL (dialog->priv->primary_label), FALSE); gtk_misc_set_alignment (GTK_MISC (dialog->priv->primary_label), 0.0, 0.0); dialog->priv->secondary_label = gtk_label_new (NULL); gtk_label_set_line_wrap (GTK_LABEL (dialog->priv->secondary_label), TRUE); gtk_label_set_single_line_mode (GTK_LABEL (dialog->priv->secondary_label), FALSE); gtk_misc_set_alignment (GTK_MISC (dialog->priv->secondary_label), 0.0, 0.0); /* Create the check button to ignore future warnings */ dialog->priv->ignore_check_button = gtk_check_button_new (); /* The button should be inactive if the dialog was just called. * I suppose it could be possible for the user to manually edit the GSettings key between * the mount being checked and the dialog appearing, but I don't think it matters * too much */ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->ignore_check_button), FALSE); g_signal_connect (dialog->priv->ignore_check_button, "toggled", G_CALLBACK (ignore_check_button_toggled_cb), dialog); /* Now set up the dialog's GtkBox's' */ gtk_box_set_spacing (GTK_BOX (main_vbox), 14); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); gtk_container_set_border_width (GTK_CONTAINER (hbox), 5); text_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); gtk_box_pack_start (GTK_BOX (text_vbox), dialog->priv->primary_label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (text_vbox), dialog->priv->secondary_label, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (text_vbox), dialog->priv->ignore_check_button, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), text_vbox, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0); /* Set up the action area */ gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_action_area (GTK_DIALOG (dialog))), 6); gtk_container_set_border_width (GTK_CONTAINER (gtk_dialog_get_action_area (GTK_DIALOG (dialog))), 5); gtk_widget_show_all (hbox); }
/* callback to unset window urgency hint on focus */ gboolean window_focus_cb(GtkWindow* window) { gtk_window_set_urgency_hint(window, FALSE); return FALSE; }
/* callback to set window urgency hint on beep events */ static void window_urgency_hint_cb(VteTerminal* vte, gpointer user_data) { gtk_window_set_urgency_hint(GTK_WINDOW (gtk_widget_get_toplevel(GTK_WIDGET (vte))), TRUE); }
void fallback_dialog_show (Defaults* d, const gchar* sender, const gchar* app_name, int id, const gchar* title_text, const gchar* _body_message, gchar** actions) { GtkWidget* dialog; GtkWidget* hbox; GtkWidget* vbox; GtkWidget* title; GtkWidget* body; GtkWidget* image; gchar* body_message = NULL; gchar* new_body_message = NULL; guint gap = EM2PIXELS (defaults_get_margin_size (d), d); gboolean success = FALSE; GError* error = NULL; if (!IS_DEFAULTS (d) || !sender || !app_name || !title_text || !_body_message || !actions) return; DialogInfo* dialog_info = g_new0 (DialogInfo, 1); if (!dialog_info) return; dialog_info->id = id; dialog_info->sender = g_strdup(sender); dialog = gtk_dialog_new (); hbox = g_object_new (GTK_TYPE_HBOX, "spacing", gap, "border-width", 12, NULL); // We deliberately use the gtk-dialog-warning icon rather than // the specified one to discourage people from trying to use // the notification system as a way of showing custom alert // dialogs. image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG); gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0); gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0); vbox = g_object_new (GTK_TYPE_VBOX, NULL); title = gtk_label_new (NULL); gtk_label_set_text (GTK_LABEL (title), title_text); gtk_label_set_line_wrap (GTK_LABEL (title), TRUE); body = gtk_label_new (NULL); body_message = filter_text (_body_message); if (body_message) { success = pango_parse_markup (body_message, -1, 0, NULL, &new_body_message, NULL, &error); if (error && !success) { g_warning ("fallback_dialog_show(): Got error \"%s\"\n", error->message); g_error_free (error); error = NULL; } } if (new_body_message) { gtk_label_set_text (GTK_LABEL (body), new_body_message); g_free (new_body_message); } else gtk_label_set_text (GTK_LABEL (body), body_message); g_free (body_message); gtk_label_set_line_wrap (GTK_LABEL (body), TRUE); gtk_misc_set_alignment (GTK_MISC (title), 0.0, 0.0); gtk_box_pack_start (GTK_BOX (vbox), title, TRUE, TRUE, 0); gtk_misc_set_alignment (GTK_MISC (body), 0.0, 0.0); gtk_box_pack_start (GTK_BOX (vbox), body, TRUE, TRUE, 0); gtk_container_add (GTK_CONTAINER (hbox), vbox); gtk_container_add (GTK_CONTAINER ( gtk_dialog_get_content_area ( GTK_DIALOG (dialog))), hbox); gtk_container_set_border_width (GTK_CONTAINER (dialog), 2); gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER); gtk_window_set_default_size (GTK_WINDOW (dialog), EM2PIXELS (defaults_get_bubble_width (d) * 1.2f, d), -1); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); gtk_window_set_title (GTK_WINDOW (dialog), app_name); gtk_window_set_urgency_hint (GTK_WINDOW (dialog), TRUE); // is it a bad notification with actions? if (actions[0] != NULL) add_pathological_action_buttons (dialog, actions); GtkButton *cancel = GTK_BUTTON ( gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL)); g_signal_connect_swapped (G_OBJECT (cancel), "button-release-event", G_CALLBACK (handle_close), dialog); gtk_widget_set_can_default(GTK_WIDGET(cancel), FALSE); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (handle_close), dialog); GtkButton *ok = GTK_BUTTON ( gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_OK, GTK_RESPONSE_OK)); g_object_set_data_full (G_OBJECT (ok), "_libnotify_action", g_strdup ("default"), g_free); g_signal_connect (G_OBJECT (ok), "button-release-event", G_CALLBACK (handle_response), dialog); gtk_widget_set_can_default(GTK_WIDGET(ok), FALSE); g_object_set_data (G_OBJECT (dialog), "_dialog_info", dialog_info); g_signal_connect (G_OBJECT (dialog), "button-release-event", G_CALLBACK (handle_response), dialog); gtk_window_set_focus (GTK_WINDOW (dialog), NULL); gtk_window_set_default (GTK_WINDOW (dialog), NULL); gtk_widget_show_all (dialog); }