int panel_start(panel *p, FILE *fp) { line s; long pos; /* parse global section */ ENTER; s.len = 256; memset(p, 0, sizeof(panel)); p->allign = ALLIGN_CENTER; p->edge = EDGE_BOTTOM; p->widthtype = WIDTH_PERCENT; p->width = 100; p->heighttype = HEIGHT_PIXEL; p->height = PANEL_HEIGHT_DEFAULT; p->setdocktype = 1; p->setstrut = 1; p->round_corners = 0; p->transparent = 0; p->alpha = 127; p->tintcolor = 0xFFFFFFFF; p->spacing = 0; fbev = fb_ev_new(); if ((get_line(fp, &s) != LINE_BLOCK_START) || g_ascii_strcasecmp(s.t[0], "Global")) { ERR( "fbpanel: config file must start from Global section\n"); RET(0); } if (!panel_parse_global(p, fp)) RET(0); if (!(pconf = tmpfile())) { ERR("can't open temporary file\n"); RET(0); } pos = ftell(fp); while (get_line_as_is(fp, &s) != LINE_NONE) fprintf(pconf, "%s\n", s.str); fseek(fp, pos, SEEK_SET); while (get_line(fp, &s) != LINE_NONE) { if ((s.type != LINE_BLOCK_START) || g_ascii_strcasecmp(s.t[0], "Plugin")) { ERR( "fbpanel: expecting Plugin section\n"); RET(0); } if (!panel_parse_plugin(p, fp)) RET(0); } gtk_widget_show_all(p->topgwin); print_wmdata(p); RET(1); }
static void panel_start(xconf *xc) { int i; xconf *pxc; ENTER; fbev = fb_ev_new(); //xconf_prn(stdout, xc, 0, FALSE); panel_parse_global(xconf_find(xc, "global", 0)); for (i = 0; (pxc = xconf_find(xc, "plugin", i)); i++) panel_parse_plugin(pxc); RET(); }
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; }