Ejemplo n.º 1
0
static void create_base_gui(appdata_s *ad)
{
    // Window
    ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE);
    elm_win_conformant_set(ad->win, EINA_TRUE);
    elm_win_autodel_set(ad->win, EINA_TRUE);

    if (elm_win_wm_rotation_supported_get(ad->win))
    {
        int rots[4] =
        { 0, 90, 180, 270 };
        elm_win_wm_rotation_available_rotations_set(ad->win, (const int *) (&rots), 4);
    }

    evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL);

    // Conformant
    ad->conform = elm_conformant_add(ad->win);
    evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    elm_win_resize_object_add(ad->win, ad->conform);
    evas_object_show(ad->conform);

    // Base Layout
    ad->layout = elm_layout_add(ad->conform);
    evas_object_size_hint_weight_set(ad->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    elm_layout_theme_set(ad->layout, "layout", "application", "default");
    evas_object_show(ad->layout);

    elm_object_content_set(ad->conform, ad->layout);

    // Naviframe
    ad->nf = elm_naviframe_add(ad->layout);
    create_list_view(ad);
    elm_object_part_content_set(ad->layout, "elm.swallow.content", ad->nf);
    eext_object_event_callback_add(ad->nf, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
    eext_object_event_callback_add(ad->nf, EEXT_CALLBACK_MORE, eext_naviframe_more_cb, NULL);

    // Show window after base gui is set up
    evas_object_show(ad->win);

}
Ejemplo n.º 2
0
void fm_folder_view_set_mode(FmFolderView* fv, FmFolderViewMode mode)
{
    if( mode != fv->mode )
    {
        GtkTreeSelection* ts;
        GList *sels, *cells;
        FmFolderModel* model = (FmFolderModel*)fv->model;
        gboolean has_focus;

        if( G_LIKELY(fv->view) )
        {
            has_focus = GTK_WIDGET_HAS_FOCUS(fv->view);
            /* preserve old selections */
            sels = fm_folder_view_get_selected_tree_paths(fv);

            g_signal_handlers_disconnect_by_func(fv->view, on_drag_motion, fv);
            g_signal_handlers_disconnect_by_func(fv->view, on_drag_leave, fv);
            g_signal_handlers_disconnect_by_func(fv->view, on_drag_drop, fv);
            g_signal_handlers_disconnect_by_func(fv->view, on_drag_data_received, fv);

            fm_dnd_unset_dest_auto_scroll(fv->view);

            gtk_widget_destroy(fv->view );
            /* FIXME: compact view and icon view actually use the same
             * type of widget, ExoIconView. So it may be better to
             * reuse the widget when available. */
        }
        else
        {
            sels = NULL;
            has_focus = FALSE;
        }

        if(fv->icon_size_changed_handler)
        {
            g_signal_handler_disconnect(fm_config, fv->icon_size_changed_handler);
            fv->icon_size_changed_handler = 0;
        }

        fv->mode = mode;
        switch(fv->mode)
        {
        case FM_FV_COMPACT_VIEW:
        case FM_FV_ICON_VIEW:
        case FM_FV_THUMBNAIL_VIEW:
            create_icon_view(fv, sels);
            break;
        case FM_FV_LIST_VIEW: /* detailed list view */
            create_list_view(fv, sels);
        }
        g_list_foreach(sels, (GFunc)gtk_tree_path_free, NULL);
        g_list_free(sels);

        /* FIXME: maybe calling set_icon_size here is a good idea */

        gtk_drag_source_set(fv->view, GDK_BUTTON1_MASK,
            fm_default_dnd_src_targets, N_FM_DND_SRC_DEFAULT_TARGETS,
            GDK_ACTION_COPY|GDK_ACTION_MOVE|GDK_ACTION_LINK|GDK_ACTION_ASK);
        fm_dnd_src_set_widget(fv->dnd_src, fv->view);

        gtk_drag_dest_set(fv->view, 0,
            fm_default_dnd_dest_targets, N_FM_DND_DEST_DEFAULT_TARGETS,
            GDK_ACTION_COPY|GDK_ACTION_MOVE|GDK_ACTION_LINK|GDK_ACTION_ASK);
        fm_dnd_dest_set_widget(fv->dnd_dest, fv->view);
        g_signal_connect_after(fv->view, "drag-motion", G_CALLBACK(on_drag_motion), fv);
        g_signal_connect(fv->view, "drag-leave", G_CALLBACK(on_drag_leave), fv);
        g_signal_connect(fv->view, "drag-drop", G_CALLBACK(on_drag_drop), fv);
        g_signal_connect(fv->view, "drag-data-received", G_CALLBACK(on_drag_data_received), fv);
        g_signal_connect(fv->view, "button-press-event", G_CALLBACK(on_btn_pressed), fv);

        fm_dnd_set_dest_auto_scroll(fv->view, gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(fv)), gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(fv)));

        gtk_widget_show(fv->view);
        gtk_container_add((GtkContainer*)fv, fv->view);

        if(has_focus) /* restore the focus if needed. */
            gtk_widget_grab_focus(fv->view);
    }
    else
    {
        /* g_debug("same mode"); */
    }
}
Ejemplo n.º 3
0
int APIENTRY WinMain(HINSTANCE instance, HINSTANCE prev, LPSTR line, int show)
{
  WNDCLASSEXA wnd;
  HWND window, hwnd_lv;
  MSG msg;
  int result = 0;
  
  g_mutex = CreateMutex(NULL, FALSE, NULL);
  CreateDirectoryA("log", NULL);
  windivert_control(DEFAULT_RULE);
  
  /* Cria janela... */
  wnd.cbSize          = sizeof(WNDCLASSEX);
  wnd.style           = CS_HREDRAW | CS_VREDRAW;
  wnd.lpfnWndProc     = (WNDPROC) window_callback;
  wnd.cbClsExtra      = 0;
  wnd.cbWndExtra      = 0;
  wnd.hInstance       = instance;
  wnd.hIcon           = (HICON) LoadImage(NULL, "icon_128x128.ico", IMAGE_ICON, 0, 0, LR_LOADFROMFILE | LR_DEFAULTSIZE | LR_SHARED);
  wnd.hIconSm         = (HICON) LoadImage(NULL, "icon_128x128.ico", IMAGE_ICON, 0, 0, LR_LOADFROMFILE | LR_DEFAULTSIZE | LR_SHARED);
  wnd.hCursor         = LoadCursor(NULL, IDC_ARROW);
  wnd.hbrBackground   = (HBRUSH)GetStockObject(DKGRAY_BRUSH); /* (HBRUSH)(COLOR_WINDOW+1); */
  wnd.lpszClassName   = w_class_name;
  wnd.lpszMenuName    = NULL;
  
  if (!RegisterClassExA(&wnd)) {
    MessageBoxA(0, "Error register class!", "Error!", MB_OK | MB_ICONERROR);
    return 1;
  }
  
  /* Janela principal. */
  window = CreateWindowExA(0, w_class_name, TITLE, WS_BORDER | WS_CAPTION 
    /*| WS_MAXIMIZEBOX*/ | WS_MINIMIZEBOX | WS_SYSMENU,
    (GetSystemMetrics(SM_CXSCREEN) - WIDTH) / 2, (GetSystemMetrics(SM_CYSCREEN) - HEIGHT) / 2,
    WIDTH, HEIGHT, HWND_DESKTOP, NULL, instance, NULL);
  
  if (!window) {
    MessageBoxA(0, "Create window!", "Error!", MB_OK | MB_ICONERROR);
    return 1;
  }
  
  /* Listview. */
  HFONT font = CreateFontA(16, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET, 
    OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, "Arial");
  
  hwnd_lv = CreateWindowExA(0, w_class_name, NULL, WS_CHILD | WS_VISIBLE,
      0, 30, WIDTH-8, (HEIGHT / 3) - 30, window, (HMENU) 1, (HINSTANCE) instance, NULL);
  
  if (hwnd_lv) {
    if ((listview = create_list_view(hwnd_lv))) {
      if ((result = init_list_view(listview)) == FALSE) {
        MessageBoxA(NULL, "Listview error.", "Error!", MB_OK | MB_ICONERROR);
        ExitProcess(0);
      } else {
        SendMessage(listview, (0x1000+54), 0, 32);
        
        content_window = CreateWindowA("EDIT", "", 
          WS_CHILD | WS_VISIBLE | ES_LEFT | ES_WANTRETURN |
          ES_AUTOVSCROLL | ES_MULTILINE, 0, 
          (HEIGHT / 3) + 1, (WIDTH-8)/4, ((HEIGHT / 3) * 2) - 25,
          window, (HMENU) HM_EDIT_CONTENT, instance, NULL );
          
        packet_content = CreateWindowA("EDIT", "", 
          WS_CHILD | WS_VISIBLE | ES_LEFT | ES_WANTRETURN |
          ES_AUTOVSCROLL | ES_MULTILINE, (WIDTH-8)/4, 
          (HEIGHT / 3) + 1, (WIDTH-8)/4, ((HEIGHT / 3) * 2) - 25,
          window, (HMENU) HM_EDIT_CONTENT, instance, NULL );
          
        payload_content = CreateWindowA("EDIT", "", 
          WS_CHILD | WS_VISIBLE | ES_LEFT | ES_WANTRETURN |
          ES_AUTOVSCROLL | ES_MULTILINE | WS_VSCROLL, ((WIDTH-8)/4)*2, 
          (HEIGHT / 3) + 1, ((WIDTH-8)/4)*2, ((HEIGHT / 3) * 2) - 25,
          window, (HMENU) HM_EDIT_CONTENT, instance, NULL );
         
        SendMessageA(content_window, WM_SETFONT, (WPARAM) font, TRUE);
        SendMessageA(packet_content, WM_SETFONT, (WPARAM) font, TRUE);
        SendMessageA(payload_content, WM_SETFONT, (WPARAM) font, TRUE);
      }
    }
  }
  
  /* Controles. */
  #define offsetlv 680
  
  windivert_edit_control = CreateWindowA("EDIT", "true", 
    WS_CHILD | /*WS_VISIBLE |*/ ES_LEFT | ES_WANTRETURN | ES_AUTOHSCROLL, 
    5, 5, 500, 20,
    window, (HMENU) HM_EDIT_CONTENT, instance, NULL );
  
  SendMessageA(windivert_edit_control, EM_SETLIMITTEXT, (WPARAM) 0x7FFFFFFE, 0);
  SendMessageA(windivert_edit_control, WM_SETFONT, (WPARAM) font, TRUE);
  
  HWND button_start_windivert = CreateWindowA( 
    "BUTTON", "START",
    WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
    510+offsetlv, 5, 50, 20,
    window, (HMENU) HM_BTN_START_WINDIVERT, instance, NULL);
  
  HWND button_stop_windivert = CreateWindowA( 
    "BUTTON", "STOP",
    WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
    560+offsetlv, 5, 50, 20,
    window, (HMENU) HM_BTN_STOP_WINDIVERT, instance, NULL);
  
  /* ShowWindow(window, SW_MAXIMIZE); */
  ShowWindow(window, SW_SHOWNORMAL);
  UpdateWindow(window);
  
  while (GetMessage(&msg, NULL, 0, 0) > 0) {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
  }
  
  return (int) msg.wParam;
}