all repos — tint2 @ 5faf063f967d6367886b671b7b5e2df8d2d05e56

fork of the tint2 desktop panel for my custom setup - only minimized windows across all desktops for the taskbar

Add config option startup_notifications = 0/1

git-svn-id: http://tint2.googlecode.com/svn/trunk@737 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
o9000 o9000
commit

5faf063f967d6367886b671b7b5e2df8d2d05e56

parent

c900bc24b2188942face02cafa7517aeb0232cec

M src/config.csrc/config.c

@@ -651,6 +651,9 @@ }

else if (strcmp(key, "launcher_tooltip") == 0) { launcher_tooltip_enabled = atoi(value); } + else if (strcmp(key, "startup_notifications") == 0) { + startup_notifications = atoi(value); + } /* Tooltip */ else if (strcmp (key, "tooltip_show_timeout") == 0) {
M src/launcher/launcher.csrc/launcher/launcher.c

@@ -55,6 +55,7 @@ int launcher_brightness;

char *icon_theme_name_config; char *icon_theme_name_xsettings; XSettingsClient *xsettings_client; +int startup_notifications; Imlib_Image scale_icon(Imlib_Image original, int icon_size); void free_icon(Imlib_Image icon);

@@ -70,6 +71,7 @@ launcher_brightness = 0;

icon_theme_name_config = NULL; icon_theme_name_xsettings = NULL; xsettings_client = NULL; + startup_notifications = 0; }

@@ -118,7 +120,7 @@ if (xsettings_client)

xsettings_client_destroy(xsettings_client); for (i = 0 ; i < nb_panel ; i++) { Panel *panel = &panel1[i]; - Launcher *launcher = &panel->launcher; + Launcher *launcher = &panel->launcher; cleanup_launcher_theme(launcher); } for (l = panel_config.launcher.list_apps; l ; l = l->next) {

@@ -243,10 +245,10 @@ // Loading default icon failed, draw a blank icon

free(new_icon_path); } else { // Loaded icon successfully - launcherIcon->icon_scaled = scale_icon(launcherIcon->icon_original, launcherIcon->icon_size); - free(launcherIcon->icon_path); - launcherIcon->icon_path = new_icon_path; - fprintf(stderr, "launcher.c %d: Using icon %s\n", __LINE__, launcherIcon->icon_path); + launcherIcon->icon_scaled = scale_icon(launcherIcon->icon_original, launcherIcon->icon_size); + free(launcherIcon->icon_path); + launcherIcon->icon_path = new_icon_path; + fprintf(stderr, "launcher.c %d: Using icon %s\n", __LINE__, launcherIcon->icon_path); } } }

@@ -386,49 +388,54 @@ {

char *cmd = malloc(strlen(icon->cmd) + 10); sprintf(cmd, "(%s&)", icon->cmd); #if HAVE_SN - SnLauncherContext* ctx; - Time time; - + SnLauncherContext* ctx; + Time time; + if (startup_notifications) { ctx = sn_launcher_context_new(server.sn_dsp, server.screen); sn_launcher_context_set_name(ctx, icon->icon_tooltip); sn_launcher_context_set_description(ctx, "Application launched from tint2"); sn_launcher_context_set_binary_name (ctx, icon->cmd); // Get a timestamp from the X event if (evt->type == ButtonPress || evt->type == ButtonRelease) { - time = evt->xbutton.time; - } - else { - fprintf(stderr, "Unknown X event: %d\n", evt->type); + time = evt->xbutton.time; + } else { + fprintf(stderr, "Unknown X event: %d\n", evt->type); free(cmd); return; } sn_launcher_context_initiate(ctx, "tint2", icon->cmd, time); + } #endif /* HAVE_SN */ pid_t pid; pid = fork(); if (pid < 0) { fprintf(stderr, "Could not fork\n"); - } - else if (pid == 0) { + } else if (pid == 0) { + // Child process #if HAVE_SN - sn_launcher_context_setup_child_process (ctx); + if (startup_notifications) { + sn_launcher_context_setup_child_process(ctx); + } #endif // HAVE_SN // Allow children to exist after parent destruction - setsid (); + setsid(); // Run the command execl("/bin/sh", "/bin/sh", "-c", icon->cmd, NULL); - fprintf(stderr, "Failed to execlp %s\n", icon->cmd); #if HAVE_SN - sn_launcher_context_unref (ctx); + if (startup_notifications) { + sn_launcher_context_unref(ctx); + } #endif // HAVE_SN - _exit(1); - } + exit(1); + } else { + // Parent process #if HAVE_SN - else { - g_tree_insert (server.pids, GINT_TO_POINTER (pid), ctx); - } + if (startup_notifications) { + g_tree_insert(server.pids, GINT_TO_POINTER (pid), ctx); + } #endif // HAVE_SN + } free(cmd); }
M src/launcher/launcher.hsrc/launcher/launcher.h

@@ -43,6 +43,7 @@ extern int launcher_brightness;

extern char *icon_theme_name_xsettings; // theme name extern char *icon_theme_name_config; extern XSettingsClient *xsettings_client; +extern int startup_notifications; // default global data void default_launcher();
M src/tint.csrc/tint.c

@@ -148,6 +148,8 @@ --error_trap_depth;

} static void sigchld_handler(int sig) { + if (!startup_notifications) + return; if (!sn_pipe_valid) return; ssize_t wur = write(sn_pipe[1], "x", 1);

@@ -156,6 +158,8 @@ fsync(sn_pipe[1]);

} static void sigchld_handler_async() { + if (!startup_notifications) + return; // Wait for all dead processes pid_t pid; while ((pid = waitpid(-1, NULL, WNOHANG)) > 0) {

@@ -213,18 +217,20 @@ XSetErrorHandler ((XErrorHandler) server_catch_error);

#ifdef HAVE_SN // Initialize startup-notification - server.sn_dsp = sn_display_new (server.dsp, error_trap_push, error_trap_pop); - server.pids = g_tree_new (cmp_ptr); - // Setup a handler for child termination - if (pipe(sn_pipe) != 0) { - fprintf(stderr, "Creating pipe failed.\n"); - } else { - sn_pipe_valid = 1; - struct sigaction act; - memset (&act, 0, sizeof (struct sigaction)); - act.sa_handler = sigchld_handler; - if (sigaction(SIGCHLD, &act, 0)) { - perror("sigaction"); + if (startup_notifications) { + server.sn_dsp = sn_display_new (server.dsp, error_trap_push, error_trap_pop); + server.pids = g_tree_new (cmp_ptr); + // Setup a handler for child termination + if (pipe(sn_pipe) != 0) { + fprintf(stderr, "Creating pipe failed.\n"); + } else { + sn_pipe_valid = 1; + struct sigaction act; + memset (&act, 0, sizeof (struct sigaction)); + act.sa_handler = sigchld_handler; + if (sigaction(SIGCHLD, &act, 0)) { + perror("sigaction"); + } } } #endif // HAVE_SN

@@ -273,10 +279,12 @@ cleanup_timeout();

if (server.dsp) XCloseDisplay(server.dsp); #ifdef HAVE_SN - if (sn_pipe_valid) { - sn_pipe_valid = 0; - close(sn_pipe[1]); - close(sn_pipe[0]); + if (startup_notifications) { + if (sn_pipe_valid) { + sn_pipe_valid = 0; + close(sn_pipe[1]); + close(sn_pipe[0]); + } } #endif }

@@ -1160,7 +1168,8 @@ if (FD_ISSET(x11_fd, &fdset)) {

while (XPending (server.dsp)) { XNextEvent(server.dsp, &e); #if HAVE_SN - sn_display_process_event (server.sn_dsp, &e); + if (startup_notifications) + sn_display_process_event(server.sn_dsp, &e); #endif // HAVE_SN panel = get_panel(e.xany.window);
M src/tint2conf/properties.csrc/tint2conf/properties.c

@@ -108,7 +108,7 @@

GtkWidget *launcher_icon_size, *launcher_icon_theme, *launcher_padding_x, *launcher_padding_y, *launcher_spacing; GtkWidget *margin_x, *margin_y; GtkWidget *launcher_background; - +GtkWidget *startup_notifications; IconThemeWrapper *icon_theme; GtkListStore *backgrounds;

@@ -1780,7 +1780,7 @@ gtk_label_set_use_markup(GTK_LABEL(label), TRUE);

gtk_widget_show(label); gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); - table = gtk_table_new(6, 10, FALSE); + table = gtk_table_new(7, 10, FALSE); gtk_widget_show(table); gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING);

@@ -1836,7 +1836,6 @@ gtk_misc_set_alignment(GTK_MISC(label), 0, 0);

gtk_widget_show(label); gtk_table_attach(GTK_TABLE(table), label, 6, 7, 2, 3, GTK_FILL, 0, 0, 0); - launcher_icon_theme = gtk_combo_box_new_with_model(GTK_TREE_MODEL(icon_themes)); GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(launcher_icon_theme), renderer, FALSE);

@@ -1844,6 +1843,15 @@ gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(launcher_icon_theme), renderer, "text", iconsColDescr, NULL);

g_signal_connect(G_OBJECT(launcher_icon_theme), "changed", G_CALLBACK(launcher_icon_theme_changed), NULL); gtk_widget_show(launcher_icon_theme); gtk_table_attach(GTK_TABLE(table), launcher_icon_theme, 7, 8, 2, 3, GTK_FILL, 0, 0, 0); + + label = gtk_label_new(_("Startup notifications")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 2, 3, 3, 4, GTK_FILL, 0, 0, 0); + + startup_notifications = gtk_check_button_new(); + gtk_widget_show(startup_notifications); + gtk_table_attach(GTK_TABLE(table), startup_notifications, 3, 4, 3, 4, GTK_FILL, 0, 0, 0); change_paragraph(parent);
M src/tint2conf/properties.hsrc/tint2conf/properties.h

@@ -121,7 +121,7 @@

extern GtkWidget *launcher_icon_size, *launcher_icon_theme, *launcher_padding_x, *launcher_padding_y, *launcher_spacing; extern GtkWidget *margin_x, *margin_y; extern GtkWidget *launcher_background; - +extern GtkWidget *startup_notifications; extern IconThemeWrapper *icon_theme; void load_desktop_file(const char *file, gboolean selected);
M src/tint2conf/properties_rw.csrc/tint2conf/properties_rw.c

@@ -393,6 +393,7 @@ fprintf(fp, "launcher_icon_theme = %s\n", icon_theme);

g_free(icon_theme); icon_theme = NULL; } + fprintf(fp, "startup_notifications = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(startup_notifications)) ? 1 : 0); int index; for (index = 0; ; index++) {

@@ -1118,6 +1119,9 @@ free(path);

} else if (strcmp(key, "launcher_icon_theme") == 0) { set_current_icon_theme(value); + } + else if (strcmp(key, "startup_notifications") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(startup_notifications), atoi(value)); } /* Tooltip */