int main(int argc, char *argv[], char *env[]) { int i; void configure(); FILE *pfp; /* current profile FP */ GdkPixbuf* icon; ENTER; //printf("sizeof(gulong)=%d\n", sizeof(gulong)); setlocale(LC_CTYPE, ""); gtk_set_locale(); gtk_init(&argc, &argv); XSetLocaleModifiers(""); XSetErrorHandler((XErrorHandler) handle_error); icon = gdk_pixbuf_new_from_file(IMGPREFIX "star.png", NULL); if (icon) { gtk_window_set_default_icon(icon); g_object_unref(icon); } resolve_atoms(); for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) { usage(); exit(0); } else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) { printf("fbpanel %s\n", version); exit(0); } else if (!strcmp(argv[i], "--log")) { i++; if (i == argc) { ERR( "fbpanel: missing log level\n"); usage(); exit(1); } else { log_level = atoi(argv[i]); } } else if (!strcmp(argv[i], "--configure") || !strcmp(argv[i], "-C")) { config = 1; } else if (!strcmp(argv[i], "--profile") || !strcmp(argv[i], "-p")) { i++; if (i == argc) { ERR( "fbpanel: missing profile name\n"); usage(); exit(1); } else { cprofile = g_strdup(argv[i]); } } else { printf("fbpanel: unknown option - %s\n", argv[i]); usage(); exit(1); } } gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), IMGPREFIX); signal(SIGUSR1, sig_usr); do { if (!(pfp = open_profile(cprofile))) exit(1); p = g_new0(panel, 1); g_return_val_if_fail (p != NULL, 1); if (!panel_start(p, pfp)) { ERR( "fbpanel: can't start panel\n"); exit(1); } fclose(pfp); if (config) configure(); gtk_main(); panel_stop(p); g_free(p); } while (force_quit == 0); exit(0); }
int main(int argc, char *argv[], char *env[]) { int i; ENTER; setlocale(LC_CTYPE, ""); gtk_init(&argc, &argv); XSetLocaleModifiers(""); XSetErrorHandler((XErrorHandler) handle_error); // resolve xatoms resolve_atoms(); p = g_new0(panel, 1); memset(p, 0, sizeof(panel)); p->allign = ALLIGN_CENTER; p->edge = EDGE_BOTTOM; p->widthtype = WIDTH_PERCENT; p->width = PANEL_WIDTH_DEFAULT; p->heighttype = HEIGHT_PIXEL; p->height = PANEL_HEIGHT_DEFAULT; p->setdocktype = 1; p->setstrut = 0; p->transparent = 0; p->icon_spacing = 0; p->alpha = 127; p->tintcolor = 0xFFFFFFFF; p->xtopbg = None; p->monitor = 0; p->margin = 0; p->on_primary = 0; for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) { usage(); exit(0); } else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) { printf("trayer %s\n", version); exit(0); } else if (!strcmp(argv[i], "-l")) { p->lower = 1; } else if (!strcmp(argv[i], "--edge")) { i++; if (i == argc) { ERR( "trayer: missing edge parameter value\n"); usage(); exit(1); } else { p->edge = str2num(edge_pair, argv[i], EDGE_NONE); } } else if (!strcmp(argv[i], "--align")) { i++; if (i == argc) { ERR( "trayer: missing align parameter value\n"); usage(); exit(1); } else { p->allign = str2num(allign_pair, argv[i], ALLIGN_NONE); } } else if (!strcmp(argv[i], "--margin")) { i++; if (i == argc) { ERR( "trayer: missing margin parameter value\n"); usage(); exit(1); } else { p->margin = atoi(argv[i]); } } else if (!strcmp(argv[i], "--widthtype")) { i++; if (i == argc) { ERR( "trayer: missing widthtype parameter value\n"); usage(); exit(1); } else { p->widthtype = str2num(width_pair, argv[i], WIDTH_NONE); } } else if (!strcmp(argv[i], "--width")) { i++; if (i == argc) { ERR( "trayer: missing width parameter value\n"); usage(); exit(1); } else { p->width = atoi(argv[i]); } } else if (!strcmp(argv[i], "--heighttype")) { i++; if (i == argc) { ERR( "trayer: missing heighttype parameter value\n"); usage(); exit(1); } else { p->heighttype = str2num(height_pair, argv[i], HEIGHT_NONE); } } else if (!strcmp(argv[i], "--height")) { i++; if (i == argc) { ERR( "trayer: missing height parameter value\n"); usage(); exit(1); } else { p->height = atoi(argv[i]); } } else if (!strcmp(argv[i], "--SetDockType")) { i++; if (i == argc) { ERR( "trayer: missing SetDockType parameter value\n"); usage(); exit(1); } else { p->setdocktype = str2num(bool_pair, argv[i], 0); } } else if (!strcmp(argv[i], "--SetPartialStrut")) { i++; if (i == argc) { ERR( "trayer: missing SetPartialStrut parameter value\n"); usage(); exit(1); } else { p->setstrut = str2num(bool_pair, argv[i], 0); } } else if (!strcmp(argv[i], "--transparent")) { i++; if (i == argc) { ERR( "trayer: missing transparent parameter value\n"); usage(); exit(1); } else { p->transparent = str2num(bool_pair, argv[i], 1); } } else if (!strcmp(argv[i], "--alpha")) { i++; if (i == argc) { ERR( "trayer: missing alpha parameter value\n"); usage(); exit(1); } else { p->alpha = atoi(argv[i]); } } else if (!strcmp(argv[i], "--tint")) { i++; if (i == argc) { ERR( "trayer: missing tint parameter value\n"); usage(); exit(1); } else { p->tintcolor = strtoul(argv[i], NULL, 0); } } else if (!strcmp(argv[i], "--distance")) { i++; if (i == argc) { ERR( "trayer: missing distance parameter value\n"); usage(); exit(1); } else { distance = atoi(argv[i]); } } else if (!strcmp(argv[i], "--distancefrom")) { i++; if (i == argc) { ERR( "trayer: missing distancefrom parameter value\n"); usage(); exit(1); } else { distancefrom = str2num(distancefrom_pair, argv[i], DISTANCEFROM_NONE); } } else if (!strcmp(argv[i], "--expand")) { i++; if (i == argc) { ERR( "trayer: missing expand parameter value\n"); usage(); exit(1); } else { expand = str2num(bool_pair, argv[i], 1); } } else if (!strcmp(argv[i], "--padding")) { i++; if (i == argc) { ERR( "trayer: missing padding parameter value\n"); usage(); exit(1); } else { padding = atoi(argv[i]); } } else if (!strcmp(argv[i], "--monitor")) { i++; if (i == argc) { ERR( "trayer: missing monitor parameter value\n"); usage(); exit(1); } else { if (g_ascii_isdigit(argv[i][0])) { p->monitor = atoi(argv[i]); } else if (!strcmp(argv[i], "primary")) { p->on_primary = 1; } } } else if (!strcmp(argv[i], "--iconspacing")) { i++; if (i == argc) { ERR( "trayer: missing icon padding parameter value\n"); usage(); exit(1); } else { p->icon_spacing = atoi(argv[i]); } } else { printf("trayer: unknown option - %s\n", argv[i]); usage(); exit(1); } } g_return_val_if_fail (p != NULL, 1); if (!panel_start(p)) { ERR( "trayer: can't start panel\n"); exit(1); } gtk_main(); panel_stop(p); g_free(p); exit(0); }
int main(int argc, char *argv[], char *env[]) { int i; const char* desktop_name; char *file; setlocale(LC_CTYPE, ""); #if !GLIB_CHECK_VERSION(2, 32, 0) g_thread_init(NULL); #endif /* gdk_threads_init(); gdk_threads_enter(); */ gtk_init(&argc, &argv); #ifdef ENABLE_NLS bindtextdomain ( GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR ); bind_textdomain_codeset ( GETTEXT_PACKAGE, "UTF-8" ); textdomain ( GETTEXT_PACKAGE ); #endif XSetLocaleModifiers(""); XSetErrorHandler((XErrorHandler) panel_handle_x_error); resolve_atoms(); desktop_name = g_getenv("XDG_CURRENT_DESKTOP"); is_in_lxde = desktop_name && (0 == strcmp(desktop_name, "LXDE")); for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) { usage(); exit(0); } else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) { printf("lxpanel %s\n", version); exit(0); } else if (!strcmp(argv[i], "--log")) { i++; if (i == argc) { g_critical( "lxpanel: missing log level"); usage(); exit(1); } else { /* deprecated */ } } else if (!strcmp(argv[i], "--configure") || !strcmp(argv[i], "-C")) { config = 1; } else if (!strcmp(argv[i], "--profile") || !strcmp(argv[i], "-p")) { i++; if (i == argc) { g_critical( "lxpanel: missing profile name"); usage(); exit(1); } else { cprofile = g_strdup(argv[i]); } } else { printf("lxpanel: unknown option - %s\n", argv[i]); usage(); exit(1); } } /* Add a gtkrc file to be parsed too. */ file = _user_config_file_name("gtkrc", NULL); gtk_rc_parse(file); g_free(file); /* Check for duplicated lxpanel instances */ if (!check_main_lock() && !config) { printf("There is already an instance of LXPanel. Now to exit\n"); exit(1); } _ensure_user_config_dirs(); /* Add our own icons to the search path of icon theme */ gtk_icon_theme_append_search_path( gtk_icon_theme_get_default(), PACKAGE_DATA_DIR "/images" ); fbev = fb_ev_new(); is_restarting = FALSE; /* init LibFM */ fm_gtk_init(NULL); /* prepare modules data */ lxpanel_prepare_modules(); init_static_plugins(); load_global_config(); /* NOTE: StructureNotifyMask is required by XRandR * See init_randr_support() in gdkscreen-x11.c of gtk+ for detail. */ gdk_window_set_events(gdk_get_default_root_window(), GDK_STRUCTURE_MASK | GDK_SUBSTRUCTURE_MASK | GDK_PROPERTY_CHANGE_MASK); gdk_window_add_filter(gdk_get_default_root_window (), (GdkFilterFunc)panel_event_filter, NULL); if( G_UNLIKELY( ! start_all_panels() ) ) g_warning( "Config files are not found.\n" ); /* * FIXME: configure?? if (config) configure(); */ gtk_main(); XSelectInput (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), GDK_ROOT_WINDOW(), NoEventMask); gdk_window_remove_filter(gdk_get_default_root_window (), (GdkFilterFunc)panel_event_filter, NULL); /* destroy all panels */ g_slist_foreach( all_panels, (GFunc) gtk_widget_destroy, NULL ); g_slist_free( all_panels ); all_panels = NULL; g_free( cfgfile ); free_global_config(); lxpanel_unload_modules(); fm_gtk_finalize(); /* gdk_threads_leave(); */ g_object_unref(fbev); if (!is_restarting) return 0; if (strchr(argv[0], G_DIR_SEPARATOR)) execve(argv[0], argv, env); else execve(g_find_program_in_path(argv[0]), argv, env); return 1; }