File indexing completed on 2024-04-28 05:32:20
0001 /* 0002 this file is part of the oxygen gtk engine 0003 SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr> 0004 SPDX-FileCopyrightText: 2010 Ruslan Kabatsayev <b7.10110111@gmail.com> 0005 0006 based on the Null Theme Engine for Gtk+. 0007 SPDX-FileCopyrightText: 2008 Robert Staudinger <robert.staudinger@gmail.com> 0008 0009 SPDX-License-Identifier: LGPL-2.0-or-later 0010 */ 0011 0012 #include "oxygentheme.h" 0013 0014 #include "config.h" 0015 #include "oxygenrcstyle.h" 0016 #include "oxygenstyle.h" 0017 #include "oxygenstylewrapper.h" 0018 #include "oxygenwindecooptions.h" 0019 #include "oxygenwindowshadow.h" 0020 #include "oxygentimelineserver.h" 0021 0022 #include <gmodule.h> 0023 #include <gtk/gtk.h> 0024 0025 #include <iostream> 0026 #include <fstream> 0027 #include <string> 0028 #include <vector> 0029 #include <sys/stat.h> 0030 0031 0032 //_________________________________________________ 0033 int theme_exit_callback( gpointer ) 0034 { 0035 theme_exit(); 0036 return false; 0037 } 0038 0039 //_________________________________________________ 0040 void theme_init( GTypeModule* module ) 0041 { 0042 0043 #if OXYGEN_DEBUG 0044 std::cerr << "Oxygen::theme_init" << std::endl; 0045 #endif 0046 0047 Oxygen::RCStyle::registerType( module ); 0048 Oxygen::StyleWrapper::registerType( module ); 0049 Oxygen::StyleWrapper::registerVersionType(); 0050 0051 // style initialization 0052 Oxygen::Style::instance().initialize(); 0053 0054 // // add quit function to make sure theme is de-allocated properly 0055 // gtk_quit_add( gtk_main_level(), theme_exit_callback, 0x0 ); 0056 0057 } 0058 0059 //_________________________________________________ 0060 void theme_exit( void ) 0061 { 0062 0063 #if OXYGEN_DEBUG 0064 std::cerr << "Oxygen::theme_exit" << std::endl; 0065 #endif 0066 0067 // delete style instance 0068 delete &Oxygen::Style::instance(); 0069 delete &Oxygen::TimeLineServer::instance(); 0070 0071 } 0072 0073 //_________________________________________________ 0074 GtkRcStyle* theme_create_rc_style( void ) 0075 { return GTK_RC_STYLE( g_object_new( Oxygen::RCStyle::type(), NULL ) ); } 0076 0077 //_________________________________________________ 0078 const gchar* g_module_check_init( GModule *module ) 0079 { 0080 return gtk_check_version( 0081 GTK_MAJOR_VERSION, 0082 GTK_MINOR_VERSION, 0083 GTK_MICRO_VERSION - GTK_INTERFACE_AGE ); 0084 } 0085 0086 //_________________________________________________ 0087 void drawWindowDecoration(cairo_t* context, unsigned long options, gint x,gint y,gint w,gint h, const gchar** ws, gint til, gint tir) 0088 { 0089 Oxygen::Style::instance().drawWindowDecoration( context, (Oxygen::WinDeco::Options) options, x, y, w, h, ws, til, tir); 0090 } 0091 0092 //_________________________________________________ 0093 void drawWindecoButton(cairo_t* context, unsigned long buttonType,unsigned long buttonState, unsigned long windowState, gint x,gint y,gint w,gint h) 0094 { 0095 Oxygen::Style::instance().drawWindecoButton( 0096 context, (Oxygen::WinDeco::ButtonType)buttonType, 0097 (Oxygen::WinDeco::ButtonStatus)buttonState, (Oxygen::WinDeco::Options) windowState, x, y, w, h); 0098 } 0099 0100 //_________________________________________________ 0101 void drawWindecoShapeMask(cairo_t* context, unsigned long options, gint x,gint y,gint w,gint h) 0102 { 0103 Oxygen::Style::instance().drawWindecoShapeMask( context, (Oxygen::WinDeco::Options) options, x, y, w, h); 0104 } 0105 0106 //_________________________________________________ 0107 void drawWindowShadow(cairo_t* context, unsigned long options, gint x, gint y, gint w, gint h) 0108 { 0109 Oxygen::Style::instance().drawWindowShadow(context,(Oxygen::WinDeco::Options) options, x, y, w, h); 0110 } 0111 0112 //_________________________________________________ 0113 gint getWindecoMetric(unsigned long wm) 0114 { 0115 return Oxygen::WinDeco::getMetric((Oxygen::WinDeco::Metric)wm); 0116 } 0117 0118 //_________________________________________________ 0119 gint getWindecoButtonSize(unsigned long buttonType) 0120 { 0121 return Oxygen::WinDeco::getButtonSize(); 0122 } 0123 0124 //_________________________________________________ 0125 unsigned long getWindecoABIVersion(void) 0126 { return 0x3; }